home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / clang / bcpp11.zip / MANUAL.TXT < prev    next >
Text File  |  1994-09-08  |  102KB  |  2,713 lines

  1. ==============================================================================
  2.  
  3. George Vanous                  THE BESTLibrary++
  4.  
  5.                                  documentation       last updated: Sep 8, 1994
  6.  
  7.  
  8. NOTE  this library (and this documentation) is NOT complete!  I am still
  9.       developing The BESTLibrary++, and am producing updates almost daily.
  10.  
  11. If this release is more than a week old, chances are I have made some
  12. significant improvements -- just request the newest version and I will gladly
  13. email it to you.
  14.  
  15. ------------------------------------------------------------------------------
  16.  
  17.                                TABLE OF CONTENTS
  18.  
  19. PREFACE.................................introduction to The BESTLibrary++
  20. BRIEF HISTORY...........................brief history of The BESTLibrary++
  21. CODING STYLE............................Hungarian-Slovak coding convention
  22. THE BESTLIBRARY++.......................documentation
  23.  globals................................ global variables
  24.  data types............................. data types (array, linked list, ...)
  25.  graphics............................... graphics (bitmap, 2D/3D, primitives)
  26.  keyboard............................... keyboard control
  27.  string................................. string classes
  28.  text mode.............................. text mode control/windowing
  29.  timer.................................. timers and stopwatches
  30. HOW TO CONTACT THE AUTHOR...............how to contact me
  31. PROGRAMMING PITFALLS....................pitfalls I have experienced (USEFUL!)
  32. PROGRAMMING TIPS........................tips I have found helpful   (USEFUL!)
  33. PROGRAMMING IDEAS.......................ideas for programming projects
  34. PROGRAMMING QUESTIONS...................some questions and answers
  35. DOS DEBUG...............................DOS's DEBUG.COM commands
  36. FREEWARE TITLES.........................quality freeware programs (incomplete)
  37. DISCLAIMER..............................our legal system requires one of these
  38.  
  39. ==============================================================================
  40. ----------------------------------  PREFACE  ---------------------------------
  41.  
  42.                    ----------------------------------------
  43.                       GOALS OF WRITING THE BESTLIBRARY++
  44.                    ----------------------------------------
  45. There are several goals I am trying to meet with The BESTLibrary++:
  46. 1) provide a robust freeware C++ object library for all programmers
  47. 2) meet other programmers through email, telephone, or postal (snail) mail
  48. 3) create a base onto which other programmers can build on by offering
  49.    their source code for inclusion in future releases of The BESTLibrary++
  50.  
  51. If we all help support freeware, we can ALL benefit.  See the end of this
  52. documentation, under FREEWARE TITLES, for a catalog of known freeware.
  53.  
  54.                      ------------------------------------
  55.                         IS THE BESTLIBRARY++ FREEWARE?
  56.                      ------------------------------------
  57. Of course.
  58.  
  59. I will release the library, documentation, and source to the demos as
  60. freeware (as I did for The BESTLibrary v2.31, this library's predecessor).
  61.  
  62. AND I will also release the source code to The BESTLibrary++ to the public
  63. domain.  With this gesture of good will (and 500++ hours of development time),
  64. I hope you will take the time to leave some feedback to me, perhaps in the way
  65. of suggestions on how to improve The BESTLibrary++, bug reports, or source
  66. code contributions.
  67.  
  68. I want to hear from you!
  69.  
  70.                                 --------------
  71.                                    COMMENTS
  72.                                 --------------
  73. If there is something you need that is not present in this library, please
  74. contact me and I will probably input it.  If you find any mistakes or
  75. inconsistencies in this documentation, do let me know.
  76.  
  77. This is no ordinary object library.  I have spent a great deal of time
  78. designing an elegant class hierarchy (and think I have succeeded).  If you
  79. have *any* recommendations or comments on my design, please let me know.  I
  80. am always looking to improve this library.
  81.  
  82. You can contact me via email: vanous@helix.net
  83. or call me at (604)589-2675 or write to me:  George Vanous
  84.                                              8930 Watson Court
  85.                                              Delta, BC
  86.                                              V4C 4T6
  87.  
  88. Although I by no means require it, I do appreciate monetary donations.  I am
  89. the typical university student who has to deal with expensive, rising tuition
  90. fees, and pay for equally expensive course books.
  91.  
  92.  
  93.                       -----------------------------------
  94.                          WHAT THE BESTLIBRARY++ CAN DO
  95.                       -----------------------------------
  96. = data types
  97.   - arrays, linked lists, queues, stacks
  98. = graphics
  99.   - SVGA upto 1280x1024x256 resolution (through SVGACC)
  100.   - windows (primitive)
  101.   - 2D primitives (line, rectangle, circle, etc.)
  102.   - 2D vector movement, rotation, scaling
  103.     - solid or wireframe display
  104.     - multi-layer motion of solid 2D vector objects (can go "underneath")
  105.   - 3D vector movement, rotation, scaling
  106.     - solid surfaces with hidden surface removal or wireframe display
  107.   - 55 screen clears and 4 screen fill patterns
  108. = keyboard
  109.   - keypress information
  110.   - direct keyboard control to block out every key (CTRL-ALT-DEL, PAUSE, etc)
  111.     - detect multiple keypresses (ie. holding down left and up arrow keys)
  112. = text mode
  113.   - cursor
  114.   - windows (advanced)
  115.     - multi-layer movement
  116.     - resize, scroll
  117.     - data entry
  118. = timers
  119.   - delays and stopwatches
  120.  
  121.                  --------------------------------------------
  122.                     WHAT THE BESTLIBRARY++ CANNOT DO (YET)
  123.                  --------------------------------------------
  124. = graphics
  125.   - 65000 and 16.7 million color modes
  126.   - virtual reality world creation
  127.   - 3D bitmap movement, rotation, scaling
  128.   - 2D/3D texture mapping
  129.   - 3D primitives (cube, sphere, etc.)
  130.   - 2D bitmap multi-layer animation, rotation, scaling
  131.   - .BMP/.GIF/.PCX/.ICO graphics manipulation
  132.   - advanced graphics mode windowing
  133. = text mode
  134.   - region definitions inside windows
  135. = string manipulation
  136.  
  137.          -----------------------------------------------------------
  138.             PROGRAMS BEING WRITTEN FOR USE WITH THE BESTLIBRARY++
  139.          -----------------------------------------------------------
  140. = REALiTY EDITOR SuperVGA
  141.   - can be used to draw:
  142.     - 2D/3D vector graphics
  143.     - bitmap icons for frame animation
  144.     - texture surfaces for 2D/3D vector objects
  145.  
  146.                                ----------------
  147.                                   THE FUTURE
  148.                                ----------------
  149. Peer into the crystal ball...
  150.  
  151. There are many projects I would like to see completed.  If you think you can
  152. help out, please let me know:
  153.  
  154. 1) hypertext word processor for creating documents with buttons, indexes,
  155.    and more (maybe animation buttons, sound buttons, and picture buttons)
  156.  
  157. 2) an entertainment pack that contains many small, but fun games; perhaps an
  158.    arkanoid clone, towers of hanoi, pong, card games, trivia, and any other
  159.    fun games
  160.  
  161. 3) robust floppy/hard disk, tape drive, CD-ROM file cataloger, with
  162.    descriptions, group categorization, searches, and quick index creation
  163.  
  164. 4) multi-player civization game that does not stop at the space age!
  165.  
  166. 5) superVGA 2D/3D graphics editor and animator for virtual reality creation
  167.  
  168. For more ideas, see PROGRAMMING IDEAS near the end of this documentation.
  169.  
  170. ==============================================================================
  171. -------------------------------  BRIEF HISTORY  ------------------------------
  172.  
  173. This library began as a collection of small .ASM functions written for
  174. assembler programmers only.  It became The BESTLibrary 1.0, with 100+
  175. functions for C programmers.  This eventually blossomed into the colossal 360
  176. function library (v2.31).
  177.  
  178. I then discovered the benefits of object oriented programming using C++, and
  179. began, in May, 1994, developing a true object library: The BESTLibrary++
  180. (known in shorthand as BESTCPP).
  181.  
  182. ==============================================================================
  183. -------------------------------  CODING STYLE  -------------------------------
  184.  
  185. I have adopted the Hungarian-Slovak naming convention for naming variables.
  186. After reading my reasons for using this convention, please leave me some
  187. feedback on your opinions and preferences.
  188.  
  189. ---
  190.  
  191. Hungarian Naming, or Hungarian for short, is named after the nationality of
  192. the original developer, Charles Simonyi, who developed it as part of his
  193. doctoral dissertation on programmer productivity.
  194.  
  195. It became widely used at Xerox PARC, where Simonyi was working when he
  196. developed this practice.  It was adopted at Microsoft after Simonyi began
  197. working there, and has since become a standard of sorts.
  198.  
  199. I have found that code written using Hungarian has become much easier to read
  200. and understand.
  201.  
  202. ---
  203.  
  204. In BASIC programs, variables tend to be as short as possible.
  205.   20  LET B=10
  206.   30  FOR A=1 TO 10
  207.   40  LET B=B+A
  208.   50  NEXT A
  209.  
  210. If short names are cryptic, perhaps longer names will be more useful?
  211.   char  countOfCharacters;
  212.   char *temporary_filename;
  213.   int   number_of_files;
  214.   word  windowhandle;
  215.   long *pointerToArrayOfLongIntegers;
  216.  
  217. Hungarian is a compromise between these two extremes.
  218.   char  ch;                            // 'ch' = character
  219.   char  achFile[128];                  // 'a'  = array   'ch' = character
  220.   char *pszName;                       // 'p'  = pointer 'sz' = string
  221.   Window *pwMain;                      // 'p'  = pointer  'w' = window
  222.  
  223.  
  224. HUNGARIAN VARIABLE NAMING
  225.  
  226. Apply short, lowercase prefixes onto each variable to denote its type:
  227.  
  228.   PREFIX   DATA TYPE
  229.     a        array (compound type: ach aw)
  230.     b        boolean
  231.     ch       character
  232.     d        double
  233.     dw       unsigned long (double word)
  234.     f        floating point
  235.     gw       graphics window
  236.     i        index (compound type: isz iach)
  237.     l        long integer
  238.     ll       linked list (compound type: llptw)
  239.     p        pointer (compound type: pf, pu)
  240.     n        integer
  241.     sz       NULL-terminated string
  242.     t        tri
  243.     tw       text window
  244.     u        function
  245.     w        word
  246.     y        byte
  247.  
  248. some not common prefixes
  249.  
  250.     bt       boot type
  251.     chip     VGAChipset
  252.     vm       video mode
  253.     vmt      video mode type
  254.  
  255. Compound types can be strung together with other prefixes (ex. achFile[128])
  256.  
  257. For loop counters, use i, j, k, ...
  258.   for (i = 0; i < wLength; i++) {
  259.     for (j = 0; j < wHeight; j++) {
  260.       ...
  261.     }
  262.   }
  263.  
  264. HUNGARIAN-SLOVAK VARIABLE NAMING
  265.  
  266. Hungarian-Slovak is a modified Hungarian naming convention created be me,
  267. George Vanous (named after my nationality of birth -- however, I am now
  268. Canadian).
  269.  
  270. Onto Hungarian, append suffixes that better describe the variable.
  271.  void move(int nX_new, int nY_new);
  272.  void move_rel(int nX_delta, int nY_delta);
  273.  void copy_tmp() { nLength_tmp = nLength_new, nHeight_tmp = nHeight_new; }
  274.  
  275.   COMMON SUFFIXES   COMMON USES
  276.        _avg           average value
  277.        _cur           current value
  278.        _def           definition
  279.        _delta         a change in
  280.        _dir           direction
  281.        _init          initialization value
  282.        _max           maximum value
  283.        _min           minimum value
  284.        _new           new value
  285.        _old           old value
  286.        _off           offset value
  287.        _org           original value
  288.        _tmp           temporary value
  289.  
  290.  
  291. HUNGARIAN-SLOVAK FUNCTION NAMING
  292.  
  293. Eacho function contains a prefix that describes its purpose:
  294.   bool is_cursor_on();
  295.   void stretch_rel(int nX_delta, nY_delta);
  296.   int  get_win_length();
  297.   int  put_chr(int nX_new, int nY_new, char ch);
  298.   void set_border_color(int nFgColor_new, int nBgColor_new);
  299. Because they are always in lowercase, functions are easy to distinguish from
  300. variables.
  301.  
  302.   COMMON PREFIXES   COMMON USES
  303.        is_            functions that return bool
  304.        get_           functions that return a value
  305.        put_           functions that output something
  306.        set_           functions that set something
  307.  
  308.  
  309. HUNGARIAN-SLOVAK CLASS NAMING
  310.  
  311. Append the _def suffix for all inherited classes -- the useable class type
  312. will never have a _def suffix:
  313.   class _2d_location_def {
  314.   protected:
  315.     int nX, nY;
  316.     ...
  317.   };
  318.  
  319.   class _2d_pixel : public _2d_location_def {
  320.     ...
  321.   };
  322.  
  323.   .
  324.   .
  325.   .
  326.  
  327.   _2d_pixel mypixel;
  328. This way, it is easy to distinguish classes that are designed to be inherited
  329. from classes that are ready for use.
  330.  
  331. ==============================================================================
  332. -----------------------------  THE BESTLIBRARY++  ----------------------------
  333.  
  334.   --------------------------------------------------------------------------
  335. -----------------------------------  NOTES  ----------------------------------
  336.  
  337. = angles are measured so that there are 256° in a full rotation (not 360°)
  338. = all coordinates have a domain of -32767..32767
  339.   - (0,0) is the center of the screen
  340.   - x is positive right and negative left
  341.   - y is positive down and negative up
  342.   - z is positive towards and negative away
  343. = some functions in BESTCPPx.HPP are not documented
  344.   - this is not an error; these functions represent undocumented features
  345.  
  346.   --------------------------------------------------------------------------
  347. --------------------------------  DATA TYPES  --------------------------------
  348.  
  349. array...................arrays for random access
  350. list, linked, double....doubly linked list for faster searches
  351. list, linked, single....singly linked list for less memory consumption
  352. list, lisp..............Lisp-like lists
  353. queue...................queues for FIFO access
  354. stack...................stacks for LIFO access
  355.  
  356.   --------------------------------------------------------------------------
  357. ---------------------------------  GRAPHICS  ---------------------------------
  358.  
  359. 2D bitmap objects.......movement, rotation, scaling of 2D bitmap objects
  360. 2D vector objects.......movement, rotation, scaling of 2D vector objects
  361. 3D bitmap objects.......movement, rotation, scaling of 3D bitmap objects
  362. 3D vector objects.......movement, rotation, scaling of 3D vector objects
  363. primitives..............pixels, lines, squares/rectangle, circles/ellipses
  364. screen fills............various background patterns and screen clears
  365. windowing...............simple window definitions and scrolling
  366.  
  367.   --------------------------------------------------------------------------
  368. ---------------------------------  KEYBOARD  ---------------------------------
  369.  
  370. keyboard................keypress information, direct control, multi-key press
  371.  
  372.   --------------------------------------------------------------------------
  373. ---------------------------------  TEXT MODE  --------------------------------
  374.  
  375. cursor..................text cursor control
  376. special effects.........special text mode effects
  377. windowing...............multi-layer windowing: moving, resizing, data entry
  378.  
  379.   --------------------------------------------------------------------------
  380. -----------------------------------  TIMER  ----------------------------------
  381.  
  382. timer...................delays and stopwatches
  383.  
  384.   --------------------------------------------------------------------------
  385. ----------------------------------  STRING  ----------------------------------
  386.  
  387. string..................string functions
  388.  
  389. ==============================================================================
  390.  
  391.  
  392. ==============================================================================
  393. ----------------------------------  GLOBALS  ---------------------------------
  394.  
  395. GLOBAL TYPES
  396. ------------
  397. pFunc                                  // function pointer
  398. ptw                                    // text window pointer
  399. byte                                   // (0-255) type as in Pascal
  400. shortint                               // (-128 to +127) type as in Pascal
  401. word                                   // (0-65535) type as in Pascal
  402. dword                                  // (0-4,294,967,295)
  403.  
  404. bool   { false, true }
  405. tri    { no, yes, sortof }
  406. action { nothing, all, morphing, moving, rotating, scaling, stretching, wireframe_toggle }
  407. colors { black, blue, green, cyan, red, magenta, brown, lightgray, darkgray,
  408.          lightblue, lightgreen, lightcyan, lightred, lightmagenta, yellow,
  409.          white }
  410. boot_type  { cold, warm }
  411. alignment  { none, horizontal, vertical, center, right_justify }
  412. direction  { stop, up, left, down, right, up_left, down_left, down_right,
  413.              up_right }
  414. video_mode { _80x25, _80x50, _640x480x16, _320x200x256, _640x400x256,
  415.              _640x480x256, _800x600x256, _1024x768x256, _1280x1024x256 }
  416. video_mode_type { _text, _mono, _graphics }
  417. cpu_type { _8086, _8088, _80186, _80286, _80386, _80486, _80586 }
  418.  
  419. days   { Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday }
  420. days3  { Mon, Tue, Wed, Thu, Fri, Sat, Sun }
  421. months { January, February, March, April, May, June, July, August, September,
  422.          October, November, December }
  423.  
  424. cards       { two, three, four, five, six, seven, eight, nine, jack, queen,
  425.               king, ace }
  426. card_suites { clubs, spades, hearts, diamonds }
  427.  
  428. continents { Africa, Antarctica, Arctic, Asia, Europe, NorthAmerica,
  429.              SouthAmerica }
  430. provinces  { BritishColumbia, Albert, Saskatchewan, Manitoba, Ontario, Quebec,
  431.              NovaScotia, NewBrunswick, PrinceEdwardIsland, PEI, Yukon,
  432.              NorthwestTerritories }
  433.  
  434. GLOBAL VARIABLES
  435. ----------------
  436. const int viewx1, viewy1,              // provided by SVGACC
  437.           viewx2, viewy2;              // current viewport dimensions
  438. int viewz1, viewz2;                    // provided by The BESTLibrary++
  439. bool abKeys[256];                      // keys currently depressed
  440. byte ayKeypadKeys[],                   // keypad movement keys
  441.      ayOKSPKeys[],                     // OK;. movement keys
  442.      ayTFHBKeys[],                     // TFHB movement keys
  443.      ayWADXKeys[],                     // WADX movement keys
  444.      ayWindowSingle[],                 // single border all around
  445.      ayWindowDouble[],                 // double border all around
  446.      ayWindowSolid[],                  // solid border all around
  447.      ayWindowSingleTop[],              // single top/bottom, double sides
  448.      ayWindowDoubleTop[],              // double top/bottom, single sides
  449.      ayWindowSingleTopOnly[],          // single top/bottom, no sides
  450.      ayWindowDoubleTopOnly[],          // double top/bottom, no sides
  451.      ayWindowSolidTopOnly[];           // solid top/bottom, no sides
  452. char **pachVGACards,                   // description of every supported card
  453.      **pachVGAFonts;                   // available font filenames
  454. int nX_max, nY_max,                    // maximum (x,y) set by BESTCPP
  455.    *pnLookupAtan,                      // integer arctan lookup table
  456.    *pnLookupSin,                       // integer sine lookup table
  457.    *pnLookupCos;                       // integer cosine lookup table
  458. long *plLookupSin,                     // long sine lookup table
  459.      *plLookupCos,                     // long cosine lookup table
  460.      *plLookupSlopeX,                  // long slope run lookup table
  461.      *plLookupSlopeY;                  // long slope rise lookup table
  462. float *pfLookupSin,                    // float sine lookup table
  463.       *pfLookupCos;                    // float cosine lookup table
  464. keyboard_def   key;                    // handle keypresses
  465. mouse_def      mouse;                  // handle mouse
  466. txt_screen_def txt;                    // text screen
  467. video_def      video;                  // video mode information
  468. MouseCursor
  469.   msArrowBig,                          // arrow directions
  470.   msArrowDiag1, msArrowDiag2,
  471.   msArrowHand1, msArrowHand2, msArrowHand3, msArrowHand4, msArrowHand5, msArrowHand6,
  472.   msArrowHorz,
  473.   msArrowInput,
  474.   msArrowNorm,
  475.   msArrowVert1, msArrowVert2,
  476.   msClock,                             // shapes
  477.   msPickbox1, msPickbox2, msPickbox3, msPickbox4, msPickbox5, msPickbox6, msPickbox7, msPickbox8,
  478.   msPixel,
  479.   msSquare,
  480.   msXHairs;
  481.  
  482. ==============================================================================
  483. --------------------------------  DATA TYPES  --------------------------------
  484.  
  485. ------------------------------------------------------------------------------
  486. Array
  487. -----
  488. NOTES:
  489. > The bottom of the array is the item that was first "add"ed.  The top is the
  490.   most recently "add"ed item.
  491. > Because it takes some time for the array to resize itself when it gets full,
  492.   take care to use an initial number of slots so as to minimize resizing.
  493.  
  494. constructor: array_def(word wCount_init = 5);
  495. > "count_init" is the initial number of indexes (this is not a maximum -- the
  496.   number of indexes will grow automatically when there are no more free ones,
  497.   by increments of "count_init")
  498.  
  499. void add(T item);
  500. > add "item" onto the top of the array
  501.  
  502. void apply(void (*func)(T& item));
  503. > call "func" for each element in the array, passing in each "item"
  504.  
  505. bool find(T item, word& wIndex);
  506. > search for "item" in the array
  507. > RETURNS  true  - successful ("wIndex" is index to item)
  508.            false - "item" was not found in array
  509.  
  510. T get_bottom();
  511. > RETURNS  item at bottom of array (first item "add"ed)
  512.  
  513. T get_current();
  514. > RETURNS  item at current index
  515.  
  516. T get_index(word wIndex);
  517. > RETURNS  item at "wIndex"
  518.            0 - "wIndex" is not a valid index (if it exceeds array)
  519.  
  520. T get_next(word wOffset = 1);
  521. > RETURNS  item at "wOffset" slots above current index
  522.            0 - "wOffset" slots above current index exceeds array
  523.  
  524. T get_prev(word wOffset = 1);
  525. > RETURNS  item at "wOffset" slots under current index
  526.            0 - "wOffset" slots under current index exceeds array
  527.  
  528. T get_top();
  529. > RETURNS  item at top of array (most recently "add"ed item)
  530.  
  531. bool goto_bottom();
  532. > set the current index to the bottom of the array
  533. > RETURNS  true  - successful
  534.            false - array is empty
  535.  
  536. bool goto_index(word wIndex);
  537. > set the current index to "wIndex"
  538. > RETURNS  true  - successful
  539.            false - there is no such index (it exceeds array)
  540.  
  541. bool goto_next(word wOffset = 1);
  542. > go forward "wOffset" slots from the current index
  543. > RETURNS  true  - successful
  544.            false - there is no such index (array is empty or at top)
  545.  
  546. bool goto_prev(word wOffset = 1);
  547. > go backward "wOffset" slots from the current index
  548. > RETURNS  true  - successful
  549.            false - there is no such index (array is empty or at bottom)
  550.  
  551. bool goto_top();
  552. > set the current index to the top of the array
  553. > RETURNS  true  - successful
  554.            false - array is empty
  555.  
  556. bool insert(T item, word wIndex);
  557. > insert "item" into the array at "wIndex"
  558. > RETURNS  true  - successful
  559.            false - "wIndex" exceeds array by more than 1
  560.  
  561. bool insert_to_bottom(T item);
  562. > insert "item" into the bottom of the array
  563. > RETURNS  true  - successful
  564.            false - array is empty
  565.  
  566. bool is_empty();
  567. > RETURNS  true  - array is empty
  568.            false - array is not empty
  569.  
  570. bool is_in(T item);
  571. > RETURNS  true  - "item" is in array
  572.            false - "item" is not in array
  573.  
  574. bool move(T item, word wIndex);
  575. > move "item" from its current position in the array to "wIndex"
  576. > RETURNS  true  - successful
  577.            false - "item" was not found in array or "wIndex" exceeds array
  578.  
  579. bool move_to_bottom(T item);
  580. > move "item" to the bottom of the array
  581. > RETURNS  true  - successful
  582.            false - "item" was not found in array
  583.  
  584. bool move_to_top(T item);
  585. > move "item" to the top of the array
  586. > RETURNS  true  - successful
  587.            false - "item" was not found in array
  588.  
  589. bool remove(T item);
  590. > remove "item"
  591. > RETURNS  true  - successful
  592.            false - "item" was not found in array
  593.  
  594. bool remove_bottom();
  595. > remove the bottom item from the array
  596. > RETURNS  true  - successful
  597.            false - array is empty
  598.  
  599. bool remove_current();
  600. > remove the item at the current index
  601. > RETURNS  true  - successful
  602.            false - array is empty
  603.  
  604. bool remove_index(word wIndex);
  605. > remove the item at "wIndex"
  606. > RETURNS  true  - successful
  607.            false - there is no such index (it exceeds array)
  608.  
  609. bool remove_next(word wOffset = 1);
  610. > remove the item that is "wOffset" slots above the current index
  611. > RETURNS  true  - successful
  612.            false - there is no such index (array is empty or exceeds array)
  613.  
  614. bool remove_prev(word wOffset = 1);
  615. > remove the item that is "wOffset" slots below the current index
  616. > RETURNS  true  - successful
  617.            false - there is no such index (array is empty or exceeds array)
  618.  
  619. bool remove_top();
  620. > remove the top item from the array
  621. > RETURNS  true  - successful
  622.            false - array is empty
  623.  
  624. void shuffle();
  625. > randomizes the order of items in the array
  626.  
  627. void sort(int (*fcmp)(const void *, const void *));
  628. = "fcmp" is a user-defined comparison routine that compares two items
  629.   and returns a value based on the comparison:
  630.  
  631.     int fcmp(const void *a, const void *b);
  632.     returns <  0  if a <  b
  633.             == 0  if a == b
  634.             >  0  if a >  b
  635.  
  636.     int sort_function(const void *pA, const void *pB);
  637.  
  638.     void main()
  639.     {
  640.       array_def<int> myarray(4);
  641.       myarray.add(5); myarray.add(3); myarray.add(12); myarray.add(7);
  642.       myarray.sort(sort_function);
  643.     }
  644.  
  645.     /* to illustrate the long way... */
  646.     int sort_function(const void *pA, const void *pB)
  647.     {
  648.       if (*(int *)pA  < *(int *)pB) return -1;
  649.       if (*(int *)pA == *(int *)pB) return  0;
  650.       if (*(int *)pA  > *(int *)pB) return  1;
  651.     }
  652.     /* the faster, better way is illustrated in the example program */
  653.  
  654. EXAMPLE PROGRAM:
  655.  
  656. #include "bestcpp.hpp"
  657.  
  658. void add_one(int& iTo);
  659. int sort_function(const void *pA, const void *pB);
  660.  
  661. void main()
  662. {
  663.   #define SHOW_ARRAY \
  664.   cout << "bottom = "       << myarray.get_bottom()  <<      \
  665.           ", top = "        << myarray.get_top()     <<      \
  666.           ", next = "       << myarray.get_next()    <<      \
  667.           ", current = "    << myarray.get_current() <<      \
  668.           ", previous = "   << myarray.get_prev()    <<      \
  669.           ", at index 2 = " << myarray.get_index(2)  << endl;
  670.  
  671.   word wIndex;
  672.   array_def<int> myarray(3);           // array of integers (3 slots)
  673.  
  674.   myarray.add(3);                      // add 3 onto array
  675.   myarray.add(5);                      // add 5 onto array
  676.   myarray.add(6);                      // add 6 onto array
  677.   myarray.add(7);                      // add 7 onto array
  678.   myarray.add(8);                      // add 8 onto array
  679.   myarray.add(9);                      // add 9 onto array
  680.   myarray.add(10);                     // add 10 onto array
  681.   myarray.insert_to_bottom(2);         // add 2 onto the bottom of the array
  682.  
  683.   myarray.move_to_top(3);              // move 3 to the top of array
  684.   myarray.move_to_bottom(6);           // move 6 to the bottom of array
  685.   myarray.move(5, 1);                  // move 5 to index 1
  686.   myarray.move(5, 3);                  // move 5 to index 3
  687.   myarray.find(5, wIndex);             // get the index of 5
  688.   myarray.insert(4, wIndex);           // insert 4 just before 5
  689.   myarray.goto_bottom();               // go to beginning of array
  690.   myarray.goto_next(2);                // jump 2 items in array
  691.   myarray.remove_current();            // remove currently indexed item
  692.   SHOW_ARRAY;                          // display current array contents
  693.  
  694.   myarray.shuffle();
  695.   SHOW_ARRAY;                          // display current array contents
  696.   myarray.sort(sort_function);
  697.   myarray.apply(add_one);              // add one to each number in array
  698.  
  699.   myarray.remove_index(1);             // remove item at index 1 from array
  700.   myarray.goto_index(2);
  701.   myarray.remove(4);                   // remove 4 from array
  702.  
  703.   if (!myarray.is_in(4))
  704.     cout << "4 is not in the array" << endl;
  705.   if (!myarray.is_empty())
  706.     cout << "array is not empty" << endl;
  707. }
  708.  
  709. void add_one(int& iTo)
  710. {
  711.   iTo++;
  712. }
  713.  
  714. int sort_function(const void *pA, const void *pB)
  715. {
  716.   return *(int *)pA - *(int *)pB;
  717. }
  718.  
  719. ------------------------------------------------------------------------------
  720. List, Linked, Double
  721. --------------------
  722. NOTES:
  723. > All functions are identical to "List, Linked, Single", with all references
  724.   to "single" changed to "double":
  725.   - "list_single" becomes "list_double"
  726.   - "node_s" becomes "node_d"
  727. > Two differences arise from the addition of a "previous" pointer in the
  728.   doubly-linked list class
  729.   1) Going to the previous node is faster (the singly linked list class has
  730.      only a "next" pointer, so it has to search from the head of the linked
  731.      list to find the previous node).
  732.   2) Unlinking a node is faster simply because finding the previous node is
  733.      faster.
  734.  
  735. EXAMPLE PROGRAM:
  736.  
  737. #include "bestcpp.hpp"
  738.  
  739. void add_one(int *piTo);
  740.  
  741. void main()
  742. {
  743.   list_double<int> mylist;             // linked list of integers
  744.   int *piX = new int(5),               // pointer to integer = 5
  745.       *piY = new int(10);              // pointer to integer = 10
  746.  
  747.   mylist.link(piX);                    // link in "piX"
  748.   mylist.link(piY);                    // link in "piY"
  749.  
  750.   mylist.apply(add_one);               // add one to each number in list
  751.  
  752.   mylist.unlink(piX);                  // unlink "piX"
  753.   bool bFlag = mylist.unlink(piX);     // won't unlink again: returns false
  754.   cout << "flag = " << bFlag << endl;
  755.  
  756.   node_d<int> *pNode = mylist.find(piY); // get the node containing "piY"
  757.   mylist.unlink(pNode);                // unlink it
  758.  
  759.   if (mylist.is_empty())               // if linked list is empty
  760.     cout << "doubly linked list is empty" << endl;
  761. }
  762.  
  763. void add_one(int *piTo)
  764. {
  765.   (*piTo)++;
  766. }
  767.  
  768. ------------------------------------------------------------------------------
  769. List, Linked, Single
  770. --------------------
  771. NOTES:
  772. > Never link the same pointer into more than one linked list
  773. > After an unlink, you are responsible for deallocating the pointer
  774. > Every item pushed must have been dynamically allocated with "new" (not
  775.   new[]).  This is so the class destructor can delete every item.
  776.  
  777. constructor: list_single();
  778.  
  779. void apply(void (*func)(T *pItem));
  780. > call "func" for each node in the linked list, passing in each node's "pItem"
  781.  
  782. node_s<T> *find(T *pItemToFind);
  783. > search for "pItemToFind" in linked list
  784. > RETURNS  node containing "pItemToFind"
  785.            0 - "pItemToFind" is not contained in linked list
  786.  
  787. bool is_empty();
  788. > RETURNS  true  - linked list is empty
  789.            false - linked list is not empty
  790.  
  791. T *get_current();
  792. > RETURNS  item at current node
  793.  
  794. void goto_head();
  795. > set the current node to the head of the list
  796.  
  797. bool goto_next();
  798. > go to the next node (from the current node)
  799. > RETURNS  true  - successful
  800.            false - there is no next node (list is empty or at end of list)
  801.  
  802. bool goto_prev();
  803. > go to the previous node (from the current node)
  804. > RETURNS  true  - successful
  805.            false - there is no previous node (list is empty or at head of list)
  806.  
  807. void link(T *pItem_new);
  808. > insert "pItem_new" into linked list
  809.  
  810. bool unlink(T *pItemToDelete);
  811. > unlink "item" from linked list and delete it
  812. > RETURNS  true  - successful
  813.            false - "item" is not contained in linked list
  814.  
  815. bool unlink(node_s<T> *pNodeToDelete);
  816. > unlink "node" from linked list and delete it
  817. > RETURNS  true  - successful
  818.            false - "node" = 0 or linked list is empty
  819.  
  820. EXAMPLE PROGRAM:
  821.  
  822. #include "bestcpp.hpp"
  823.  
  824. void add_one(int *piTo);
  825.  
  826. void main()
  827. {
  828.   list_single<int> mylist;             // linked list of integers
  829.   int *piX = new int(5),               // pointer to integer = 5
  830.       *piY = new int(10);              // pointer to integer = 10
  831.  
  832.   mylist.link(piX);                    // link in "piX"
  833.   mylist.link(piY);                    // link in "piY"
  834.  
  835.   mylist.apply(add_one);               // add one to each number in list
  836.  
  837.   mylist.unlink(piX);                  // unlink "piX"
  838.   bool bFlag = mylist.unlink(piX);     // won't unlink again: returns false
  839.   cout << "flag = " << bFlag << endl;
  840.  
  841.   node_s<int> *pNode = mylist.find(piY); // get the node containing "piY"
  842.   mylist.unlink(pNode);                // unlink it
  843.  
  844.   if (mylist.is_empty())               // if linked list is empty
  845.     cout << "singly linked list is empty" << endl;
  846. }
  847.  
  848. void add_one(int *piTo)
  849. {
  850.   (*piTo)++;
  851. }
  852.  
  853. ------------------------------------------------------------------------------
  854. List, Lisp
  855. ----------
  856.  
  857. Not written yet :(
  858.  
  859. ------------------------------------------------------------------------------
  860. Queue
  861. -----
  862. NOTES:
  863. > Never enqueue the same pointer into more than one queue
  864. > After a dequeue, you are responsible for deallocating the pointer
  865. > Every item enqueued must have been dynamically allocated with "new" (not
  866.   new[]).  This is so because the class destructor can delete every item.
  867.  
  868. constructor: queue_def(word wInitialSize_init = 5);
  869. > the size of the queue will be set to "wInitialSize_init" elements -- the
  870.   size will increase in increments of "wInitialSize_init" when the queue gets
  871.   full
  872.  
  873. void apply(void (*func)(T *pItem));
  874. > call "func" for each element in the queue, passing in each element's "pItem"
  875.  
  876. T *dequeue();
  877. > RETURNS  item first enqueued
  878.            0 - no more items in queue
  879.  
  880. void enqueue(T *pItem_new);
  881. > enqueue "pItem_new" into queue
  882.  
  883. bool is_empty();
  884. > RETURNS  true  - queue is empty
  885.            false - queue is not empty
  886.  
  887. EXAMPLE PROGRAM:
  888.  
  889. #include "bestcpp.hpp"
  890.  
  891. void add_one(int *piTo);
  892.  
  893. void main()
  894. {
  895.   queue_def<int> myqueue;              // queue for 5 (initially) integers
  896.   int *piX = new int(5),               // pointer to integer = 5
  897.       *piY,
  898.       *piZ = new int(10);              // pointer to integer = 10
  899.  
  900.   myqueue.enqueue(piX);                // add in "piX" (pointer to 5)
  901.   myqueue.enqueue(piZ);                // add in "piZ" (pointer to 10)
  902.  
  903.   myqueue.apply(add_one);              // add one to each number in list
  904.  
  905.   piY = myqueue.dequeue();             // get first value added
  906.   cout << "Y = " << *piY << endl;
  907.   delete piY;                          // deallocate
  908.  
  909.   piY = myqueue.dequeue();             // try on empty queue: returns 0
  910.   cout << "Y = " << *piY << endl;
  911.   delete piY;                          // deallocate
  912.  
  913.   if (myqueue.is_empty())              // if queue is empty
  914.     cout << "queue is empty" << endl;
  915. }
  916.  
  917. void add_one(int *piTo)
  918. {
  919.   (*piTo)++;
  920. }
  921.  
  922. ------------------------------------------------------------------------------
  923. Stack
  924. -----
  925. NOTES:
  926. > Never push the same pointer onto more than one stack
  927. > After a pop, you are responsible for deallocating the pointer
  928. > Any items not popped are deallocated by the class destructor
  929.  
  930. constructor: stack_def();
  931.  
  932. void apply(void (*func)(T *pItem));
  933. > call "func" for each node in the stack, passing in each node's "pItem"
  934.  
  935. bool is_empty();
  936. > RETURNS  true  - stack is empty
  937.            false - stack is not empty
  938.  
  939. T *pop();
  940. > RETURNS  item last pushed
  941.            0 - no more items on stack
  942.  
  943. bool push(T *pItem_new);
  944. > push "pItem_new" onto stack
  945. > RETURNS  true  - successful
  946.            false - "pItem_new" = 0
  947.  
  948. EXAMPLE PROGRAM:
  949.  
  950. #include "bestcpp.hpp"
  951.  
  952. void add_one(int *piTo);
  953.  
  954. void main()
  955. {
  956.   stack_def<int> mystack;              // stack of integers
  957.   int *piX = new int(5);               // pointer to integer = 5
  958.   int *piY,
  959.       *piZ = new int(10);              // pointer to integer = 10
  960.  
  961.   mystack.push(piX);                   // push "piX" on stack
  962.   mystack.push(piZ);                   // push "piZ" on stack
  963.  
  964.   mystack.apply(add_one);              // add one to each number in list
  965.  
  966.   piY = mystack.pop();                 // pop off last value pushed on
  967.   cout << "Y = " << *piY << endl;
  968.   delete piY;                          // deallocate
  969.  
  970.   piY = mystack.pop();                 // try on empty stack: returns 0
  971.   cout << "Y = " << *piY << endl;
  972.   delete piY;                          // deallocate
  973.  
  974.   if (mystack.is_empty())              // if stack is empty
  975.     cout << "stack is empty" << endl;
  976. }
  977.  
  978. void add_one(int *piTo)
  979. {
  980.   (*piTo)++;
  981. }
  982.  
  983. ==============================================================================
  984.  
  985.  
  986. ==============================================================================
  987. ---------------------------------  GRAPHICS  ---------------------------------
  988.  
  989. NOTES:
  990. > Graphics will only show themselves on one page at a time.
  991. > "show()" and "hide()" will display only if object is "set_visible(true)"
  992. > For flicker-free animation, make sure "video.page_swap()" is called before
  993.   any animation begins.
  994. > When all objects have been "show()"n, call "video.done()", then "done()"
  995.   for all the objects.
  996.     _2d_line myline(50, 100, 50, 30, yellow);
  997.     _2d_circle mycircle(10, 10, 50, lightgreen, true);
  998.     video.page_swap();                 // need to do this before animation
  999.  
  1000.     while (true) {                     // endless loop
  1001.       myline.move(-10, -5);            // move the line
  1002.       mycircle.move(10, 5);            // move the circle
  1003.  
  1004.       myline.show();                   // done manipulating -- show it now
  1005.       mycircle.show();                 // done manipulating -- show it now
  1006.  
  1007.       video.done();                    // needed after everything is "show()"n
  1008.  
  1009.       myline.done();                   // tell all objects they are "done()"
  1010.       mycircle.done();                 // tell all objects they are "done()"
  1011.     }
  1012.  
  1013. COMMON TO ALL GRAPHIC OBJECTS
  1014. -----------------------------
  1015. DEFAULT VALUES:
  1016. > movement keys       = ayKeypadKeys
  1017. > movement steps      = 5
  1018. > movement directions = 1
  1019. > movement increments = 1
  1020. > set_move_mode(1)
  1021. > stop_moving()         "set_move_mode(1)" calls "start_moving()"
  1022.  
  1023. void done();
  1024. > perform cleanup work after a "show()" and "video.done()"
  1025.  
  1026. int get_x();
  1027. > RETURNS  x-coordinate of object
  1028.  
  1029. int get_y();
  1030. > RETURNS  y-coordinate of object
  1031.  
  1032. byte get_move_mode();
  1033. > RETURNS  mode of movement
  1034.  
  1035. byte get_rebound_mode();
  1036. > RETURNS  method of dealing with border collisions
  1037.  
  1038. void hide();
  1039. > hide the object from the current active page
  1040.  
  1041. void interact(void (*puBg)(bool bShow) = 0);
  1042. > give the user control over the graphic object
  1043. > calls function "puBg(true)"  during interaction (to show all graphics)
  1044. > calls function "puBg(false)" during interaction (to hide all graphics)
  1045. > RETURNS  when user presses ENTER or ESC
  1046.  
  1047. void interact_move();
  1048. > if a movement key was pressed, the object is moved accordingly
  1049. > if the object is in motion, the object is moved accordingly
  1050.  
  1051. bool is_onscreen(int nX_new, int nY_new);
  1052. > RETURNS  true  - object is onscreen at "nX_new","nY_new"
  1053.            false - object is not onscreen at "nX_new","nY_new"
  1054.  
  1055. bool is_onscreen_rel(int nX_delta, int nY_delta);
  1056. > RETURNS  true  - object is onscreen "nX_delta","nY_delta" from its current
  1057.                    position
  1058.            false - object is not onscreen "nX_delta","nY_delta" from its
  1059.                    current position
  1060.  
  1061. bool is_visible();
  1062. > RETURNS  true  - object is visible
  1063.            false - object is hidden
  1064.  
  1065. bool is_wireframe();
  1066. > RETURNS  true  - the object is in wireframe mode
  1067.            false - the object has its hidden surfaces removed
  1068.  
  1069. void rebound();
  1070. > rebound the object (called after "is_onscreen()" returns false)
  1071. > if this is the fourth time calling rebound with similar coordinates, the
  1072.   object is placed into the center of the screen
  1073.  
  1074. void set_keys_move(byte *ayKeysMove_new);
  1075. > "ayKeysMove_new" become the movement keys
  1076.  
  1077. void set_move_mode(byte yMoveMode_new, bool bSetup);
  1078. > set the mode of movement
  1079. > "bsetup" is true  - defaults are set
  1080.               false - defaults are not set
  1081. > "yMoveMode_new" is
  1082.    0 - thrust and brake only;  moves to match the currently facing direction
  1083.        since only a movement step along the y-axis is required, the movement
  1084.          step along the x-axis is set to 0
  1085.        defaults: set_rebound(2);
  1086.                  start_moving();
  1087.    1 - motion in 8 directions; rotates to match the currently facing direction
  1088.        defaults: set_rebound(1);
  1089.                  start_moving();
  1090.    2 - motion in 8 directions; rotates in multiples of 45° only
  1091.        defaults: set_rebound(3);
  1092.                  start_moving();
  1093.  
  1094. void set_rebound(byte yReboundMode_new);
  1095. > set the method of dealing with border collisions
  1096.   "yReboundMode_new" is
  1097.    0 - no checking for borders and no rebounding
  1098.    1 - if border is hit, rebound occurs
  1099.    2 - if border is hit, object appear on opposite side of screen
  1100.    3 - if border is hit, object stops moving in that direction
  1101.  
  1102. void set_visible(bool bVisible_new = true);
  1103. > "bVisible_new" is true  - object is visible
  1104.                     false - object is hidden
  1105.  
  1106. void set_wireframe(bool bWireframe_new = true);
  1107. > "bWireframe_new" is true  - the object is wireframe
  1108.                       false - the object is solid
  1109.  
  1110. void show();
  1111. > show the object on the current display page
  1112.  
  1113. void start_moving();
  1114. > start moving the object according to its direction and step rates
  1115.  
  1116. void stop_moving();
  1117. > stop moving the object
  1118.  
  1119. --------
  1120. MOVEMENT
  1121. --------
  1122. int get_move_x_dir();
  1123. > RETURNS  direction of movement along x-axis (-1 = left, +1 = right)
  1124.  
  1125. int get_move_y_dir();
  1126. > RETURNS  direction of movement along y-axis (-1 = up, +1 = down)
  1127.  
  1128. int get_move_x_inc();
  1129. > RETURNS  movement increment along x-axis
  1130.  
  1131. int get_move_y_inc();
  1132. > RETURNS  movement increment along y-axis
  1133.  
  1134. int get_move_x_step();
  1135. > RETURNS  movement rate along x-axis
  1136.  
  1137. int get_move_y_step();
  1138. > RETURNS  movement rate along y-axis
  1139.  
  1140. bool is_moving()
  1141. > RETURNS  true  - object is moving according to its direction and step rates
  1142.            false - object is not moving
  1143.  
  1144. bool is_moving_somewhere()
  1145. > RETURNS  true  - object is in motion (nonzero direction and step rates)
  1146.            false - object is not in motion (zero direction and step rates)
  1147.  
  1148. void move();
  1149. > move the object by its movement increments
  1150.  
  1151. void move(int nX_new, int nY_new);
  1152. > move the object to coordinates "nX_new","nY_new"
  1153.  
  1154. void move_rel(int nX_delta, int nY_delta);
  1155. > move the object "nX_delta","nY_delta" from its current position
  1156.  
  1157. void set_move_dir(int nMoveDir_new);
  1158. > set the movement directions along the x-axis and y-axis to "nMoveDir_new"
  1159. > typical values are -1 (left), +1 (right)
  1160. > this is multiplied with the step when moving (ex. 2 would double the speed)
  1161.  
  1162. void set_move_inc(int nMoveInc_new);
  1163. > set the movement increments along the x-axis and y-axis to "nMoveXInc_new"
  1164.  
  1165. void set_move_inc_rel(int nMoveInc_delta);
  1166. > set the movement increments along the x-axis and y-axis "nMoveXInc_delta"
  1167.   from their current values
  1168.  
  1169. void set_move_step(int nMove_new);
  1170. > set the movement step along the x-axis and y-axis to "nMove_new"
  1171.  
  1172. void set_move_step_rel(int nMove_delta);
  1173. > set the movement step along the x-axis and y-axis "nMove_delta" from its
  1174.   current value
  1175.  
  1176. void set_move_x_dir(int nMoveXDir_new);
  1177. > set the movement direction along the x-axis to "nMoveXDir_new"
  1178. > typical values are -1 (left), 0 (stop), +1 (right)
  1179. > this is multiplied with the step when moving (ex. 2 would double the speed)
  1180.  
  1181. void set_move_y_dir(int nMoveYDir_new);
  1182. > set the movement direction along the y-axis to "nMoveYDir_new"
  1183. > typical values are -1 (left), 0 (stop), +1 (right)
  1184. > this is multiplied with the step when moving (ex. 2 would double the speed)
  1185.  
  1186. void set_move_x_inc(int nMoveXInc_new);
  1187. > set the movement increments along the x-axis to "nMoveXInc_new"
  1188.  
  1189. void set_move_y_inc(int nMoveYInc_new);
  1190. > set the movement increments along the y-axis to "nMoveYInc_new"
  1191.  
  1192. void set_move_x_inc_rel(int nMoveXInc_delta);
  1193. > set the movement increments along the x-axis "nMoveXInc_delta" from its
  1194.   current value
  1195.  
  1196. void set_move_y_inc_rel(int nMoveYInc_delta);
  1197. > set the movement increments along the y-axis "nMoveYInc_delta" from its
  1198.   current value
  1199.  
  1200. void set_move_x_step(int nMoveX_new);
  1201. > set the movement step along the x-axis to "nMoveX_new"
  1202.  
  1203. void set_move_y_step(int nMoveY_new);
  1204. > set the movement step along the y-axis to "nMoveY_new"
  1205.  
  1206. void set_move_x_step_rel(int nMoveX_delta);
  1207. > set the movement step along the x-axis "nMoveX_delta" from its current
  1208.   value
  1209.  
  1210. void set_move_y_step_rel(int nMoveY_delta);
  1211. > set the movement step along the y-axis "nMoveY_delta" from its current
  1212.   value
  1213.  
  1214. COMMON TO ALL GRAPHIC OBJECTS THAT CAN STRETCH THEMSELVES
  1215. --------------------------------------------------------
  1216. void interact_stretch();
  1217. > if a stretch key was pressed, the object is stretched accordingly
  1218. > if the object is in a continuous stretch, the object is stretched
  1219.   accordingly
  1220.  
  1221. COMMON TO ALL GRAPHIC OBJECTS THAT CAN ROTATE THEMSELVES
  1222. --------------------------------------------------------
  1223. int  get_x_axis()                                      { return nXAxis; }
  1224. int  get_y_axis()                                      { return nYAxis; }
  1225. int  get_angle()                                       { return nAngle; }
  1226. void interact_spin();
  1227. void rotate(int nAngle_new)                            { rotscale(nAngle_new, nScale); }
  1228. void rotate_rel(int nAngle_delta)                      { rotate(nAngle+nAngle_delta); }
  1229. void rotscale_rel(int nAngle_delta, int nScale_delta)  { rotscale(nAngle+nAngle_delta, nScale+nScale_delta); }
  1230. void scale(int nScale_new)                             { rotscale(nAngle, nScale_new); }
  1231. void scale_rel(int nScale_delta)                       { scale(nScale+nScale_delta); }
  1232. void set_axes(int nX_new, int nY_new);
  1233. void set_axes_rel(int nX_delta, int nY_delta)          { set_axes(nXAxis+nX_delta, nYAxis+nY_delta); }
  1234. void set_x_axis(int nX_new)                            { set_axes(nX_new, nYAxis); }
  1235. void set_x_axis_rel(int nX_delta)                      { set_x_axis(nXAxis+nX_delta); }
  1236. void set_y_axis(int nY_new)                            { set_axes(nXAxis, nY_new); }
  1237. void set_y_axis_rel(int nY_delta)                      { set_y_axis(nYAxis+nY_delta); }
  1238. virtual void reset() = 0;                                // pure virtual
  1239. virtual void rotscale(int nAngle_new, int nScale_new) = 0; // pure virtual
  1240.  
  1241. void interact_rotate();
  1242. > if a rotation key was pressed, the object is rotated accordingly
  1243. > if the object is in rotation, the object is rotated accordingly
  1244.  
  1245. void interact_scale();
  1246. > if a scale key was pressed, the object is scale accordingly
  1247. > if the object is in a continuous scale, the object is scaled accordingly
  1248.  
  1249. void set_keys_orbit(byte *ayKeysOrbit_new);
  1250. > "ayKeysOrbit_new" become the orbit keys
  1251.  
  1252. void set_keys_rotate(byte *ayKeysRotate_new);
  1253. > "ayKeysRotate_new" become the rotate keys
  1254.  
  1255. void set_keys_scale(byte *ayKeysScale_new);
  1256. > "ayKeysScale_new" become the scale keys
  1257.  
  1258. void set_move_mode(byte yMoveMode_new);
  1259. > set the mode of movement (each mode is simply a macro)
  1260.   "yMoveMode_new" is
  1261.    0 - thrust and brake only; motion determined by rotation
  1262.        set_rebound(2);
  1263.        ayRotateKeys = ayMoveKeys;
  1264.    1 - motion in 8 directions; rotation determined by direction
  1265.        set_rebound(1);
  1266.    2 - motion in 8 directions; rotation determined by player
  1267.        set_rebound(3);
  1268.  
  1269. ==============================================================================
  1270. 2D vector objects
  1271. =================
  1272. constructor: _2d_object_vector(int nX_init, int nY_init,
  1273.                                int *object_init, int *object_data_init,
  1274.                                byte movement_mode = 0,
  1275.                                byte *keys_move_init = keypad_keys,
  1276.                                byte *keys_rotate_init = wadx_keys,
  1277.                                int x_axis_init = 0, int y_axis_init = 0,
  1278.                                bool visible_init = true);
  1279. > "nX_init","nY_init" are the object's coordinates
  1280. > "movement_mode" is the mode of movement [see "set_movement" for the modes]
  1281. > "object_init" is the array of vector coordinates
  1282. > "object_data_init" is the array of commands to draw the object
  1283. > "x_axis_init","y_axis_init" are the axes
  1284. > "visible_init" is true  - object is visible
  1285.                     false - object is hidden
  1286.  
  1287. void reset();
  1288. > reset the object to its initial state
  1289.  
  1290. ----
  1291. AXES
  1292. ----
  1293. int get_x_axis();
  1294. > RETURNS  x-axis position of object
  1295.  
  1296. int get_y_axis();
  1297. > RETURNS  y-axis position of object
  1298.  
  1299. int get_angle();
  1300. > RETURNS  angle of rotation of object
  1301.  
  1302. void set_axes(int nX_new, int nY_new);
  1303. > set the x-axis and y-axis to "nX_new","nY_new"
  1304.  
  1305. void set_axes_rel(int nX_delta, int nY_delta);
  1306. > set the x-axis and y-axis "nX_delta","nY_delta" from their current positions
  1307.  
  1308. void set_x_axis(int nX_new);
  1309. > set the x-axis to "nX_new"
  1310.  
  1311. void set_x_axis_rel(int nX_delta);
  1312. > set the x-axis "nX_delta" from its current position
  1313.  
  1314. void set_y_axis(int nY_new);
  1315. > set the y-axis to "nY_new"
  1316.  
  1317. void set_y_axis_rel(int nY_delta);
  1318. > set the y-axis "nY_delta" from its current position
  1319.  
  1320. --------
  1321. MOVEMENT
  1322. --------
  1323. int get_rate_move();
  1324. > RETURNS  movement rate factor
  1325.  
  1326. int get_rate_rot();
  1327. > RETURNS  rotation rate factor
  1328.  
  1329. void set_move_rate(int rate_move_new);
  1330. > set the movement rate factor to "rate_move_new"
  1331.  
  1332. void set_move_rate_rel(int rate_move_delta);
  1333. > set the movement rate factor "rate_move_delta" from its current movement
  1334.   rate
  1335.  
  1336. void set_rotation_rate(int rate_rot_new);
  1337. > set the rotation rate factor to "rate_rot_new"
  1338.  
  1339. void set_rotation_rate_rel(int rate_rot_delta);
  1340. > set the rotation rate factor "rate_rot_delta" from its current rotation rate
  1341.  
  1342. ----------------
  1343. ROTATION/SCALING
  1344. ----------------
  1345. void rotate(int angle_to);
  1346. > rotate the object to "angle_to" degrees
  1347.  
  1348. void rotate_rel(int angle_delta);
  1349. > rotate the object "angle_to" degrees from its current rotation angle
  1350.  
  1351. void scale(int scale_to);
  1352. > scale the object to "scale_to" (128 means original size)
  1353.  
  1354. void scale_rel(int scale_delta);
  1355. > scale the object "scale_to" from its current scale factor
  1356.  
  1357. void rotscale(int angle_to, int scale_to);
  1358. > rotate the object to "angle_to" degrees
  1359. > scale the object to "scale_to" (128 means original size)
  1360.  
  1361. void rotscale_rel(int angle_delta, int scale_delta);
  1362. > rotate the object "angle_to" degrees from its current rotation
  1363. > scale the object "scale_to" from its current scale factor
  1364.  
  1365. EXAMPLE PROGRAM:
  1366.  
  1367. #include "bestcpp.hpp"
  1368.  
  1369. /* vertex coordinates */
  1370. // x,y,z of every vertex
  1371. // 32767  end of object
  1372. int pic_box[] = {
  1373.    -40,   40,  // box body                            //   0  left  down
  1374.    -40,  -40,                                         //   2  left  up
  1375.     40,  -40,                                         //   4  right up
  1376.     40,   40,                                         //   6  right down
  1377.  
  1378.     32767
  1379. };
  1380.  
  1381. /* data describing each vector */
  1382. // -2  new polygon (enclosed), number of vertexes, vertex offset
  1383. // -1  new polygon (not enclosed), number of vertexes, vertex offset
  1384. //  32767  end of object
  1385. int pic_box_data[] = {
  1386.     -2,   4,   0, lightgreen,   // box body
  1387.                2, lightgreen,
  1388.                4, lightgreen,
  1389.                6, lightgreen,
  1390.     32767
  1391. };
  1392.  
  1393. void main()
  1394. {
  1395.   video.set(_640x480x256);             // set video mode to 640x480 256 colors
  1396.  
  1397.   _2d_object_vector box(nX_max/2, nY_max/2, pic_box, pic_box_data);
  1398.   box.move_rel(10, -10);               // move box
  1399.   box.rotate_rel(10, 10);              // rotate box
  1400.   box.scale_rel(108, 142);             // scale box
  1401.  
  1402.   key.clear();                         // clear any keypress information
  1403.   do {
  1404.     key.get_ch_ready();                // get a key if one is pressed
  1405.  
  1406.     box.automatic();                   // automatically do movement/rotation
  1407.  
  1408.     msec(15);                          // wait 15 milliseconds
  1409.   } while (key.get_scan() != SCAN_ESC);
  1410. }
  1411.  
  1412. ==============================================================================
  1413. 3D vector objects
  1414. =================
  1415. constructor: _3d_object_vector(int nX_init, int nY_init, int z_init,
  1416.                                int *object_init, int *object_data_init,
  1417.                                int x_axis_init = 0, int y_axis_init = 0,
  1418.                                int z_axis_init = 0,
  1419.                                bool wireframe_init = false,
  1420.                                bool visible_init = true);
  1421. > "nX_init","nY_init","z_init" are the 3D object's coordinates
  1422. > "object_init" is the array of vector coordinates
  1423. > "object_data_init" is the array of commands to draw the object
  1424. > "x_axis_init","y_axis_init","z_axis_init" are the axes
  1425. > "wireframe_init" is true  - object is in wireframe
  1426.                       false - object has its hidden surfaces removed
  1427. > "visible_init" is true  - object is visible
  1428.                     false - object is hidden
  1429.  
  1430. void reset();
  1431. > reset the object to its initial state
  1432.  
  1433. ----
  1434. AXES
  1435. ----
  1436. int get_x();
  1437. > RETURNS  the x-coordinate of the object
  1438.  
  1439. int get_x_axis();
  1440. > RETURNS  the x-axis position of the object
  1441.  
  1442. int get_y();
  1443. > RETURNS  the y-coordinate of the object
  1444.  
  1445. int get_y_axis();
  1446. > RETURNS  the y-axis position of the object
  1447.  
  1448. int get_z();
  1449. > RETURNS  the z-coordinate of the object
  1450.  
  1451. int get_z_axis();
  1452. > RETURNS  the z-axis position of the object
  1453.  
  1454. void set_axes(int nX_new, int nY_new, int nZ_new);
  1455. > set the x,y,z-axes to "nX_new","nY_new","nZ_new"
  1456.  
  1457. void set_axes_rel(int nX_delta, int nY_delta, int nZ_delta);
  1458. > set the x,y,z-axes "nX_new","nY_new" from their current positions
  1459.  
  1460. void set_x_axis(int nX_new);
  1461. > set the x-axis to "nX_new"
  1462.  
  1463. void set_x_axis_rel(int nX_delta);
  1464. > set the x-axis "nX_delta" from its current position
  1465.  
  1466. void set_y_axis(int nY_new);
  1467. > set the y-axis to "nY_new"
  1468.  
  1469. void set_y_axis_rel(int nY_delta);
  1470. > set the y-axis "nY_delta" from its current position
  1471.  
  1472. void set_z_axis(int nZ_new);
  1473. > set the z-axis to "nZ_new"
  1474.  
  1475. void set_z_axis_rel(int nZ_delta);
  1476. > set the z-axis "nZ_delta" from its current position
  1477.  
  1478. --------
  1479. MOVEMENT
  1480. --------
  1481. void move(int nX_new, int nY_new, int nZ_new, bool orbit = false);
  1482. > move the object to "nX_new","nY_new","nZ_new"
  1483. > "orbit" is true  - the axes will remain fixed
  1484.              false - the axes will move with the object
  1485.  
  1486. void move_rel(int nX_delta, int nY_delta, int nZ_delta, bool orbit = false);
  1487. > move the object "nX_delta","nY_delta","nZ_delta" from its current position
  1488. > "orbit" is true  - the axes will remain fixed
  1489.              false - the axes will move with the object
  1490.  
  1491. void move_x(int nX_new);
  1492. > move the object to "nX_new"
  1493. > "orbit" is true  - the axes will remain fixed
  1494.              false - the axes will move with the object
  1495.  
  1496. void move_x_rel(int nX_delta, bool orbit = false);
  1497. > move the object "nX_delta" from its current position
  1498. > "orbit" is true  - the axes will remain fixed
  1499.              false - the axes will move with the object
  1500.  
  1501. void move_y(int nY_new);
  1502. > move the object to "nY_new"
  1503. > "orbit" is true  - the axes will remain fixed
  1504.              false - the axes will move with the object
  1505.  
  1506. void move_y_rel(int nY_delta, bool orbit = false);
  1507. > move the object "nY_delta" from its current position
  1508. > "orbit" is true  - the axes will remain fixed
  1509.              false - the axes will move with the object
  1510.  
  1511. void move_z(int nZ_new);
  1512. > move the object to "nZ_new"
  1513. > "orbit" is true  - the axes will remain fixed
  1514.              false - the axes will move with the object
  1515.  
  1516. void move_z_rel(int nZ_delta, bool orbit = false);
  1517. > move the object "nZ_delta" from its current position
  1518. > "orbit" is true  - the axes will remain fixed
  1519.              false - the axes will move with the object
  1520.  
  1521. --------
  1522. ROTATION
  1523. --------
  1524. void rotate(int x_angle_new, int y_angle_new, int z_angle_new);
  1525. > rotate the object to "x_angle_new","y_angle_new","z_angle_new" degrees
  1526.  
  1527. void rotate_rel(int x_angle_delta, int y_angle_delta, int z_angle_delta);
  1528. > rotate the object "x_angle_delta","y_angle_delta","z_angle_delta" degrees
  1529.   from its current x,y,z-degree rotation
  1530.  
  1531. void rotate_x(int x_angle_new);
  1532. > rotate the object to "x_angle_new" degrees about the x-axis
  1533.  
  1534. void rotate_x_rel(int theta);
  1535. > rotate the object "theta" degrees from its current x-degree rotation
  1536.  
  1537. void rotate_y(int y_angle_new);
  1538. > rotate the object to "y_angle_new" degrees about the y-axis
  1539.  
  1540. void rotate_y_rel(int theta);
  1541. > rotate the object "theta" degrees from its current y-degree rotation
  1542.  
  1543. void rotate_z(int z_angle_new);
  1544. > rotate the object to "z_angle_new" degrees about the z-axis
  1545.  
  1546. void rotate_z_rel(int theta);
  1547. > rotate the object "theta" degrees from its current z-degree rotation
  1548.  
  1549. -------
  1550. SCALING
  1551. -------
  1552. void scale(float x_scale_new, float y_scale_new, float z_scale_new);
  1553. > scale the object to "x_scale_new","y_scale_new","z_scale_new" percent
  1554.  
  1555. void scale_rel(float x_scale_delta, float y_scale_delta, float z_scale_delta);
  1556. > scale the object "x_scale_delta","y_scale_delta","z_scale_delta" percent
  1557.   from its current x,y,z-scale percentages
  1558.  
  1559. void scale_all(float xyz_scale_new);
  1560. > scale the object to "xyz_scale_new" percent for all three dimensions
  1561.  
  1562. void scale_all_rel(float xyz_scale_delta);
  1563. > scale the object "xyz_scale_delta" percent from its current x,y,z-scale
  1564.   percentages for all three dimensions
  1565.  
  1566. void scale_x(float x_scale_new);
  1567. > scale the object to "x_scale_new" percent
  1568.  
  1569. void scale_x_rel(float x_scale_delta);
  1570. > scale the object "x_scale_delta" percent from its current x-scale percentage
  1571.  
  1572. void scale_y(float y_scale_new);
  1573. > scale the object to "y_scale_new" percent
  1574.  
  1575. void scale_y_rel(float y_scale_delta);
  1576. > scale the object "y_scale_delta" percent from its current y-scale percentage
  1577.  
  1578. void scale_z(float z_scale_new);
  1579. > scale the object to "z_scale_new" percent
  1580.  
  1581. void scale_z_rel(float z_scale_delta);
  1582. > scale the object "z_scale_delta" percent from its current z-scale percentage
  1583.  
  1584. ----------
  1585. STRETCHING
  1586. ----------
  1587. void stretch(float x_stretch_new, float y_stretch_new, float z_stretch_new);
  1588. > stretch the object to "x_stretch_new","y_stretch_new","z_stretch_new"
  1589.   percent
  1590.  
  1591. void stretch_rel(float x_stretch_delta, float y_stretch_delta, float z_stretch_delta);
  1592. > stretch the object "x_stretch_delta","y_stretch_delta","z_stretch_delta"
  1593.   percent from its current x,y,z-stretch percentages
  1594.  
  1595. void stretch_x(float x_stretch_new);
  1596. > stretch the object "x_stretch_new" percent
  1597.  
  1598. void stretch_x_rel(float x_stretch_delta);
  1599. > stretch the object "x_stretch_delta" percent from its current x-stretch
  1600.   percentage
  1601.  
  1602. void stretch_y(float y_stretch_new);
  1603. > stretch the object "y_stretch_new" percent
  1604.  
  1605. void stretch_y_rel(float y_stretch_delta);
  1606. > stretch the object "y_stretch_delta" percent from its current y-stretch
  1607.   percentage
  1608.  
  1609. void stretch_z(float z_stretch_new);
  1610. > stretch the object "z_stretch_new" percent
  1611.  
  1612. void stretch_z_rel(float z_stretch_delta);
  1613. > stretch the object "z_stretch_delta" percent from its current z-stretch
  1614.   percentage
  1615.  
  1616. EXAMPLE PROGRAM:
  1617.  
  1618. #include "bestcpp.hpp"
  1619.  
  1620. /* vector coordinates */
  1621. // x,y,z of every vertex
  1622. // 32767  end of object
  1623. int pic_box[] = {
  1624.    -60,  -40,   80, // box body             //    0  left  up   towards
  1625.    -60,   40,   80,                         //    3  left  down towards
  1626.     60,   40,   80,                         //    6  right down towards
  1627.     60,  -40,   80,                         //    9  right up   towards
  1628.  
  1629.    -60,  -40,  -80,                         //   12  left  up   away
  1630.    -60,   40,  -80,                         //   15  left  down away
  1631.     60,   40,  -80,                         //   18  right down away
  1632.     60,  -40,  -80,                         //   21  right up   away
  1633.  
  1634.     32767
  1635. };
  1636.  
  1637. /* data describing each vector */
  1638. // -2  new polygon (enclosed), number of vertexes, vertex offset
  1639. // -1  new polygon (not enclosed), number of vertexes, vertex offset
  1640. //  32767  end of object
  1641. int pic_box_data[] = {
  1642.     -2,   4,   9, lightgreen,               // front surface of box
  1643.                6, lightgreen,
  1644.                3, lightgreen,
  1645.                0, lightgreen,
  1646.     -2,   4,  12, lightgreen,               // back surface of box
  1647.               15, lightgreen,
  1648.               18, lightgreen,
  1649.               21, lightgreen,
  1650.     -2,   4,   0, lightgreen,               // left surface of box
  1651.                3, lightgreen,
  1652.               15, lightgreen,
  1653.               12, lightgreen,
  1654.     -2,   4,  21, lightgreen,               // right surface of box
  1655.               18, lightgreen,
  1656.                6, lightgreen,
  1657.                9, lightgreen,
  1658.     -2,   4,  21, lightgreen,               // top surface of box
  1659.                9, lightgreen,
  1660.                0, lightgreen,
  1661.               12, lightgreen,
  1662.     -2,   4,   6, lightgreen,               // bottom surface of box
  1663.               18, lightgreen,
  1664.               15, lightgreen,
  1665.                3, lightgreen,
  1666.  
  1667.     32767
  1668. };
  1669.  
  1670. void main()
  1671. {
  1672.   video.set(_640x480x256);
  1673.  
  1674.   _3d_object_vector box(nX_max/2, nY_max/2, 0, pic_box, pic_box_data);
  1675.   box.move_rel(10, -10, 10);           // move box
  1676.   box.rotate_rel(10, 10, 0);           // rotate box
  1677.   box.scale_rel(0.80, 0.70, 0.50);     // scale box
  1678.   box.stretch_rel(0.80, 0.70, 0.50);   // stretch box
  1679.   box.set_wireframe(true);             // show box in wireframe
  1680. }
  1681.  
  1682. ==============================================================================
  1683. Primitives
  1684. ==========
  1685.  
  1686. COMMON TO ALL GRAPHIC PRIMITIVES
  1687. --------------------------------
  1688. int get_color();
  1689. > RETURNS  object's color
  1690.  
  1691. void set_color(int nColor_new);
  1692. > set the object's color to "nColor_new"
  1693.  
  1694. COMMON TO ALL GRAPHIC PRIMITIVES THAT ARE ENCLOSED SHAPES
  1695. ---------------------------------------------------------
  1696. void interact_stretch();
  1697. > if a stretch key was pressed, the object is stretched appropriately
  1698.  
  1699. bool is_solid();
  1700. > RETURNS  true  - the object is solid
  1701.            false - the object is an outline
  1702.  
  1703. void set_keys_stretch(byte *ayKeysStretch_new);
  1704. > "ayKeysStretch_new" become the stretch keys
  1705.  
  1706. void set_solid(bool bSolid_new);
  1707. > "bSolid_new" is true  - object is solid
  1708.                   false - object is an outline
  1709.  
  1710. COMMON TO ALL GRAPHIC PRIMITIVES WITH ONE LENGTH
  1711. ------------------------------------------------------
  1712. int get_length();
  1713. > RETURNS  length of object
  1714.  
  1715. void stretch(int nLength_new);
  1716. > set the object's length to "nLength_new"
  1717.  
  1718. void stretch_rel(int nLength_delta);
  1719. > set the object's length "nLength_delta" from its current length
  1720.  
  1721. COMMON TO ALL GRAPHIC PRIMITIVES WITH ONE LENGTH AND ONE HEIGHT
  1722. -----------------------------------------------------------------
  1723. int get_height();
  1724. > RETURNS  height of object
  1725.  
  1726. int get_length();
  1727. > RETURNS  length of object
  1728.  
  1729. void set_height(int height_new);
  1730. > set the object's height to "height_new"
  1731.  
  1732. void set_length(int length_new);
  1733. > set the object's length to "length_new"
  1734.  
  1735. void set_height_rel(int height_delta);
  1736. > set the object's height "height_delta" from its current height
  1737.  
  1738. void set_length_rel(int length_delta);
  1739. > set the object's length "length_delta" from its current length
  1740.  
  1741. void stretch(int nLength_new, int nHeight_new);
  1742. > set the object's dimensions to "nLength_new","nHeight_new"
  1743.  
  1744. void stretch_rel(int nLength_delta, int nHeight_delta);
  1745. > set the object's dimensions "nLength_delta","nHeight_delta" from its current
  1746.   dimensions
  1747.  
  1748. COMMON TO ALL GRAPHIC PRIMITIVES WITH TWO LENGTHS AND TWO HEIGHTS
  1749. ---------------------------------------------------------------------
  1750. int get_height1();
  1751. > RETURNS  height #1 of object
  1752.  
  1753. int get_height2();
  1754. > RETURNS  height #2 of object
  1755.  
  1756. int get_length1();
  1757. > RETURNS  length #1 of object
  1758.  
  1759. int get_length2();
  1760. > RETURNS  length #2 of object
  1761.  
  1762. void set_height1(int nHeight1_new);
  1763. > set the object's height #1 to "nHeight1_new"
  1764.  
  1765. void set_height2(int nHeight2_new);
  1766. > set the object's height #2 to "nHeight2_new"
  1767.  
  1768. void set_length1(int nLength1_new);
  1769. > set the object's length #1 to "nLength1_new"
  1770.  
  1771. void set_length2(int nLength2_new);
  1772. > set the object's length #2 to "nLength2_new"
  1773.  
  1774. void set_height1_rel(int nHeight1_delta);
  1775. > set the object's height #1 "nHeight1_delta" from its current height #1
  1776.  
  1777. void set_height2_rel(int nHeight2_delta);
  1778. > set the object's height #2 "nHeight2_delta" from its current height #2
  1779.  
  1780. void set_length1_rel(int nLength1_delta);
  1781. > set the object's length #1 "nLength1_delta" from its current length #1
  1782.  
  1783. void set_length2_rel(int nLength2_delta);
  1784. > set the object's length #2 "nLength2_delta" from its current length #2
  1785.  
  1786. void stretch(int nLength1_new, int nHeight1_new, int nLength2_new, int nHeight2_new);
  1787. > set the object's dimensions to "nLength1_new","nHeight1_new",
  1788.   "nLength2_new","nHeight2_new"
  1789.  
  1790. void stretch_rel(int nLength1_delta, int nHeight1_delta, int nLength2_delta, int nHeight2_delta);
  1791. > set the object's dimensions "nLength1_delta","nHeight1_delta",
  1792.   "nLength2_delta","nHeight2_delta" from its current dimensions
  1793.  
  1794. COMMON TO ALL GRAPHIC PRIMITIVES WITH ONE RADIUS
  1795. --------------------------------------------------------
  1796. int get_radius();
  1797. > RETURNS  object's radius
  1798.  
  1799. void stretch(int nRadius_new);
  1800. > set the object's radius to "nRadius_new"
  1801.  
  1802. void stretch_rel(int nRadius_delta);
  1803. > set the object's radius "nRadius_delta" from its current radius
  1804.  
  1805. COMMON TO ALL GRAPHIC PRIMITIVES WITH TWO RADII
  1806. -------------------------------------------------------
  1807. int get_radius_x();
  1808. > RETURNS  object's major radius (along x-axis)
  1809.  
  1810. int get_radius_y();
  1811. > RETURNS  object's minor radius (along y-axis)
  1812.  
  1813. void set_radius_x(int nRadiusx_new);
  1814. > set the object's major radius to "nRadiusx_new"
  1815.  
  1816. void set_radius_x_rel(int nRadiusx_delta);
  1817. > set the object's major radius "nRadiusx_delta" from its current major
  1818.   radius
  1819.  
  1820. void set_radius_y(int nRadiusy_new);
  1821. > set the object's minor radius to "nRadiusy_new"
  1822.  
  1823. void set_radius_y_rel(int nRadiusy_delta);
  1824. > set the object's minor radius "nRadiusy_delta" from its current minor
  1825.   radius
  1826.  
  1827. void stretch(int nRadiusx_new, int nRadiusy_new);
  1828. > set the object's radii to "nRadiusx_new","nRadiusy_new"
  1829.  
  1830. void stretch_rel(int nRadiusx_delta, int nRadiusy_delta);
  1831. > set the object's radii "nRadiusx_delta","nRadiusy_delta" from their
  1832.   current radii
  1833.  
  1834. COMMON TO ALL GRAPHIC PRIMITIVES WITH ONE RADIUS AND TWO ANGLES
  1835. -----------------------------------------------------------------------
  1836. int  get_angle_end();
  1837. > RETURNS  object's ending angle
  1838.  
  1839. int  get_angle_start();
  1840. > RETURNS  object's beginning angle
  1841.  
  1842. void set_angle_end(int nAngleEnd_new);
  1843. > set the object's ending angle to "nAngleEnd_new"
  1844.  
  1845. void set_angle_start(int nAngleStart_new);
  1846. > set the object's starting angle to "nAngleStart_new"
  1847.  
  1848. void set_angle_end_rel(int nAngleEnd_delta);
  1849. > set the object's ending angle "nAngleEnd_delta" from its current measure
  1850.  
  1851. void set_angle_start_rel(int nAngleStart_delta);
  1852. > set the object's starting angle "nAngleStart_delta" from its current measure
  1853.  
  1854. void stretch(int nAngleStart_new, int nAngleEnd_new);
  1855. > set the object's angles to "nAngleStart_new","nAngleEnd_new"
  1856.  
  1857. void stretch_rel(int nAngleStart_delta, int nAngleEnd_delta);
  1858. > set the object's angles "nAngleStart_delta","nAngleEnd_delta" from its
  1859.   current measures
  1860.  
  1861. ------------------------------------------------------------------------------
  1862. arc (not yet written)
  1863. ---
  1864. NOTES:
  1865. > graphic primitive that is an enclosed shape with one radius and two angles
  1866.  
  1867. constructor:
  1868.   _2d_arc(int nX_init, int nY_init, int nRadius_init,
  1869.           int nAngleStart_init, int nAngleEnd_init,
  1870.           int nColor_init, bool bSolid_init, bool bVisible_init = true);
  1871. > "nX_init","nY_init" are the arc's coordinates
  1872. > "nRadius_init" is the radius
  1873. > "nAngleStart_init","nAngleEnd_init" are the beginning/ending angles
  1874. > "nColor_init" is the color
  1875. > "nSolid_init" is true  - arc is solid
  1876.                    false - arc is an outline
  1877. > "bVisible_init" is true  - arc is visible
  1878.                      false - arc is not visible
  1879.  
  1880. EXAMPLE PROGRAM:
  1881.  
  1882. #include "bestcpp.hpp"
  1883.  
  1884. void main()
  1885. {
  1886.   video.set(_640x480x256);
  1887.  
  1888.   _2d_arc myarc(nX_max/2, nY_max/2, 64, 30, 210, yellow);
  1889.   myarc.move(10, -5);                  // move arc right and up
  1890.   myarc.stretch_rel(10, -5);           // change arc's angles
  1891. }
  1892.  
  1893. ------------------------------------------------------------------------------
  1894. circle
  1895. ------
  1896. NOTES:
  1897. > graphic primitive that is an enclosed shape with one radius
  1898.  
  1899. constructor:
  1900.   _2d_circle(int nX_init, int nY_init, int nRadius_init,
  1901.              int nColor_init, bool bSolid_init, bool bVisible_init = true);
  1902.  
  1903. > "nX_init","nY_init" are the circle's coordinates
  1904. > "nRadius_init" is the radius
  1905. > "nColor_init" is the color
  1906. > "bSolid_init" is true  - circle is solid
  1907.                    false - circle is an outline
  1908. > "bVisible_init" is true  - circle is visible
  1909.                      false - circle is not visible
  1910.  
  1911. EXAMPLE PROGRAM:
  1912.  
  1913. #include "bestcpp.hpp"
  1914.  
  1915. void main()
  1916. {
  1917.   video.set(_640x480x256);
  1918.  
  1919.   _2d_circle mycircle(nX_max/2, nY_max/2, 64, yellow);
  1920.   mycircle.move(10, -5);               // move circle right and up
  1921.   mycircle.stretch_rel(-16);           // change circle radius
  1922. }
  1923.  
  1924. ------------------------------------------------------------------------------
  1925. ellipse
  1926. -------
  1927. NOTES:
  1928. > graphic primitive that is an enclosed shape with two radii
  1929.  
  1930. constructor:
  1931.   _2d_ellipse(int nX_init, int nY_init, int nRadiusX_init, int nRadiusY_init,
  1932.               int nColor_init, bool bSolid_init, bool bVisible_init = true);
  1933. > "nX_init","nY_init" are the ellipse's coordinates
  1934. > "nRadiusX_init","nRadiusY_init" are the radii
  1935. > "nColor_init" is the color
  1936. > "bSolid_init" is true  - ellipse is solid
  1937.                    false - ellipse is an outline
  1938. > "bVisible_init" is true  - ellipse is visible
  1939.                      false - ellipse is not visible
  1940.  
  1941. EXAMPLE PROGRAM:
  1942.  
  1943. #include "bestcpp.hpp"
  1944.  
  1945. void main()
  1946. {
  1947.   video.set(_640x480x256);
  1948.  
  1949.   _2d_ellipse myellipse(nX_max/2, nY_max/2, 64, 32, yellow);
  1950.   myellipse.move(10, -5);              // move ellipse right and up
  1951.   myellipse.stretch_rel(-16, 8);       // change ellipse radii
  1952. }
  1953.  
  1954. ------------------------------------------------------------------------------
  1955. line
  1956. ----
  1957. NOTES:
  1958. > graphic primitive with one length and height
  1959.  
  1960. constructor:
  1961.   _2d_line(int nX_init, int nY_init, int nLength_init, int nHeight_init,
  1962.            int nColor_init, bool bVisible_init = true);
  1963. > "nX_init","nY_init" are the line's coordinates
  1964. > "nLength_init","nHeight_init" are the dimensions
  1965. > "nColor_init" is the color
  1966. > "bVisible_init" is true  - line is visible
  1967.                      false - line is not visible
  1968.  
  1969. EXAMPLE PROGRAM:
  1970.  
  1971. #include "bestcpp.hpp"
  1972.  
  1973. void main()
  1974. {
  1975.   video.set(_640x480x256);
  1976.  
  1977.   _2d_line myline(nX_max/2, nY_max/2, 64, -32, yellow);
  1978.   myline.move(10, -5);                 // move line right and up
  1979.   myline.stretch_rel(-16, -8);         // change line dimensions
  1980. }
  1981.  
  1982. ------------------------------------------------------------------------------
  1983. pixel
  1984. -----
  1985. NOTES:
  1986. > graphic primitive
  1987.  
  1988. constructor:
  1989.   _2d_pixel(int nX_init, int nY_init,
  1990.             int nColor_init, bool bVisible_init = true);
  1991. > "nX_init","nY_init" are the pixel's coordinates
  1992. > "nColor_init" is the color
  1993. > "bVisible_init" is true  - pixel is visible
  1994.                      false - pixel is not visible
  1995.  
  1996. EXAMPLE PROGRAM:
  1997.  
  1998. #include "bestcpp.hpp"
  1999.  
  2000. void main()
  2001. {
  2002.   video.set(_640x480x256);
  2003.  
  2004.   _2d_pixel mypixel(nX_max/2, nY_max/2, yellow);
  2005.   mypixel.move(10, -5);                 // move pixel right and up
  2006.   mypixel.set_color(lightblue);         // change pixel color
  2007. }
  2008.  
  2009. ------------------------------------------------------------------------------
  2010. rectangle
  2011. ---------
  2012. NOTES:
  2013. > graphic primitive that is an enclosed shape with a length and height
  2014.  
  2015. constructor:
  2016.   _2d_rectangle(int nX_init, int nY_init, int nLength_init, int nHeight_init,
  2017.                 int nColor_init, bool bSolid_init, bool bVisible_init = true);
  2018. > "nX_init","nY_init" are the rectangle's coordinates
  2019. > "nLength_init","nHeight_init" are the dimensions
  2020. > "nColor_init" is the color
  2021. > "bSolid_init" is true  - rectangle is solid
  2022.                    false - rectangle is an outline
  2023. > "bVisible_init" is true  - rectangle is visible
  2024.                      false - rectangle is not visible
  2025.  
  2026. EXAMPLE PROGRAM:
  2027.  
  2028. #include "bestcpp.hpp"
  2029.  
  2030. void main()
  2031. {
  2032.   video.set(_640x480x256);
  2033.  
  2034.   _2d_rectangle myrectangle(nX_max/2, nY_max/2, 64, -32, yellow);
  2035.   myrectangle.move(10, -5);            // move rectangle right and up
  2036.   myrectangle.stretch_rel(-16, -8);    // change rectangle dimensions
  2037. }
  2038.  
  2039. ------------------------------------------------------------------------------
  2040. square
  2041. ------
  2042. NOTES:
  2043. > graphic primitive that is an enclosed shape with one length
  2044.  
  2045. constructor:
  2046.   _2d_square(int nX_init, int nY_init, int nLength_init,
  2047.              int nColor_init, bool bSolid_init, bool bVisible_init = true);
  2048. > "nX_init","nY_init" are the square's coordinates
  2049. > "nLength_init" is the length of each side
  2050. > "nColor_init" is the color
  2051. > "bSolid_init" is true  - square is solid
  2052.                    false - square is an outline
  2053. > "bVisible_init" is true  - square is visible
  2054.                      false - square is not visible
  2055.  
  2056. EXAMPLE PROGRAM:
  2057.  
  2058. #include "bestcpp.hpp"
  2059.  
  2060. void main()
  2061. {
  2062.   video.set(_640x480x256);
  2063.  
  2064.   _2d_square mysquare(nX_max/2, nY_max/2, 64, -32, yellow);
  2065.   mysquare.move(10, -5);               // move square right and up
  2066.   mysquare.set_length_rel(-16);        // change square size
  2067. }
  2068.  
  2069. ------------------------------------------------------------------------------
  2070. triangle (not yet written)
  2071. --------
  2072. NOTES:
  2073. > graphic primitive that is an enclosed shape with two lengths and two heights
  2074.  
  2075. constructor:
  2076.   _2d_triangle(int nX_init, int nY_init, int nLength1_init, int nHeight1_init,
  2077.                int nLength2_init, int nHeight2_init,
  2078.                int nColor_init, bool bSolid_init, bool bVisible_init = true);
  2079. > "nX_init","nY_init" are the triangle's coordinates
  2080. > "nLength1_init","nHeight1_init" are the dimensions of the first side
  2081. > "nLength2_init","nHeight2_init" are the dimensions of the second side
  2082. > "nColor_init" is the color
  2083. > "bSolid_init" is true  - triangle is solid
  2084.                    false - triangle is an outline
  2085. > "bVisible_init" is true  - rectangle is visible
  2086.                      false - rectangle is not visible
  2087.  
  2088. EXAMPLE PROGRAM:
  2089.  
  2090. #include "bestcpp.hpp"
  2091.  
  2092. void main()
  2093. {
  2094.   video.set(_640x480x256);
  2095.  
  2096.   _2d_triangle mytriangle(nX_max/2, nY_max/2, 64, -32, -16, 128, yellow);
  2097.   mytriangle.move(10, -5);               // move triangle right and up
  2098.   mytriangle.set_dimensions_rel(-8, 16, 4, -64);
  2099. }
  2100.  
  2101. ==============================================================================
  2102. Screen Fills
  2103. ============
  2104. NOTES:
  2105. > video.clear(54) and video.clear(55) produce strange
  2106.   results.  If the library was not compiled with Automatic Register
  2107.   Variables, it would work fine.  This is an error in the Borland C++ 3.1
  2108.   compiler, and not my fault.
  2109.  
  2110. ------------------------------------------------------------------------------
  2111. background patterns
  2112. -------------------
  2113. void video.bg(int whichOne, int color);
  2114. > fill the current viewport with pattern "whichOne" in "color"
  2115. > "whichOne" is 0 - circles expanding outward
  2116.                 1 - radial lines of increasing color
  2117.                 2 - unusually placed lines
  2118.                 3 - unusually placed lines
  2119.  
  2120. ------------------------------------------------------------------------------
  2121. screen clears
  2122. -------------
  2123. void video.clear(int how, int ms_delay = 1, int color = black);
  2124. > clear the current viewport with pattern "how" to "color"
  2125. > pause "ms_delay" milliseconds between each output
  2126. > "how" is 0  - straight lines top to bottom
  2127.            1  - straight lines bottom to top
  2128.            2  - straight lines left to right
  2129.            3  - straight lines right to left
  2130.            4  - straight lines top and bottom open
  2131.            5  - straight lines top and bottom close
  2132.            6  - straight lines left and right open
  2133.            7  - straight lines left and right close
  2134.            8  - diagonal lines at 45° bottom-left to top-right
  2135.            9  - diagonal lines at 45° bottom-right to top-left
  2136.            10 - diagonal lines at 45° top-right to bottom-left
  2137.            11 - diagonal lines at 45° top-left to bottom-right
  2138.            12 - diagonal lines at 45° bottom-left and top-right open
  2139.            13 - diagonal lines at 45° bottom-left and top-right close
  2140.            14 - diagonal lines at 45° bottom-right and top-left open
  2141.            15 - diagonal lines at 45° bottom-right and top-left close
  2142.            16 - radial lines counterclockwise
  2143.            17 - radial lines clockwise
  2144.            18 - radial lines clock-like top clockwise
  2145.            19 - radial lines clock-like top counterclockwise
  2146.            20 - radial lines clock-like left clockwise
  2147.            21 - radial lines clock-like left counterclockwise
  2148.            22 - radial lines clock-like bottom clockwise
  2149.            23 - radial lines clock-like bottom counterclockwise
  2150.            24 - radial lines clock-like right clockwise
  2151.            25 - radial lines clock-like right counterclockwise
  2152.            26 - radial lines clock-like meet at bottom
  2153.            27 - radial lines clock-like meet at right
  2154.            28 - radial lines clock-like meet at top
  2155.            29 - radial lines clock-like meet at left
  2156.            30 - radial lines wiper-like bottom center open
  2157.            31 - radial lines wiper-like bottom center close
  2158.            32 - radial lines wiper-like right center open
  2159.            33 - radial lines wiper-like right center close
  2160.            34 - radial lines wiper-like top center open
  2161.            35 - radial lines wiper-like top center close
  2162.            36 - radial lines wiper-like left center open
  2163.            37 - radial lines wiper-like left center close
  2164.            38 - radial lines wiper-like bottom-left clockwise
  2165.            39 - radial lines wiper-like bottom-left counterclockwise
  2166.            40 - radial lines wiper-like bottom-right clockwise
  2167.            41 - radial lines wiper-like bottom-right counterclockwise
  2168.            42 - radial lines wiper-like top-right clockwise
  2169.            43 - radial lines wiper-like top-right counterclockwise
  2170.            44 - radial lines wiper-like top-left clockwise
  2171.            45 - radial lines wiper-like top-left counterclockwise
  2172.            46 - radial lines wiper-like bottom-left open
  2173.            47 - radial lines wiper-like bottom-left close
  2174.            48 - radial lines wiper-like bottom-right open
  2175.            49 - radial lines wiper-like bottom-right close
  2176.            50 - radial lines wiper-like top-right open
  2177.            51 - radial lines wiper-like top-right close
  2178.            52 - radial lines wiper-like top-left open
  2179.            53 - radial lines wiper-like top-left close
  2180.            54 - rectangles expanding outward
  2181.            55 - rectangles collapsing inward
  2182.  
  2183. ==============================================================================
  2184. Windowing
  2185. =========
  2186.  
  2187. Not yet documented.
  2188.  
  2189. ==============================================================================
  2190.  
  2191.  
  2192. ==============================================================================
  2193. ---------------------------------  KEYBOARD  ---------------------------------
  2194.  
  2195. NOTES:
  2196. > "key" is a globally accessible class of "keyboard_def".
  2197.  
  2198. not yet documented
  2199.  
  2200. ==============================================================================
  2201. ----------------------------------  STRING  ----------------------------------
  2202.  
  2203. ==============================================================================
  2204. String (not yet written)
  2205. ======
  2206. NOTES:
  2207. > All strings are NULL-terminated.
  2208.  
  2209. void clean(char& str);
  2210. > remove all control characters from "str"
  2211.  
  2212. int hash(const char& str);
  2213. > RETURNS  hashed value of "str" (sum of all characters' ASCII values)
  2214.  
  2215. char *left(const char& str, int num);
  2216. > RETURNS  string containing "num" characters of "str", counting from left
  2217.  
  2218. char *mid(const char& str, int start, int num);
  2219. > RETURNS  string containing "num" characters of "str", counting from "start"
  2220.  
  2221. void replace(char& str, const char& replace, int num, int start)
  2222. > inside "str", replace "num" characters beginning at "start" with "replace"
  2223.  
  2224. char *right(const char& str, int num);
  2225. > RETURNS  string containing "num" characters of "str", counting from right
  2226.  
  2227. char *sentence(const char& str);
  2228. > RETURNS  sentence form of "str": first letter capitalized, period appended
  2229.  
  2230. void substitute(char& str, const char& search, const char& replace,
  2231.                 int num = 0, int nth = 1)
  2232. > inside "str", replace occurrences of "serach" with "replace"
  2233. > perform "num" substitutions (if = 0, substitute every occurrence)
  2234. > begin substitution at the "nth" occurrence (1 means first occurrence)
  2235.  
  2236. ==============================================================================
  2237.  
  2238. ==============================================================================
  2239. ---------------------------------  TEXT MODE  --------------------------------
  2240.  
  2241. NOTES:
  2242. > "txt" is a globally accessible class of "txt_screen_def".
  2243. > "video" is a globally accessible class of "video_def".
  2244. > since the DOS screen is the first text window, do not modify this window if
  2245.   you wish to restore the DOS screen properly when your program exits
  2246.   > to use the DOS screen and still restore it, just create another window
  2247.     and save it (it will copy the screen contents into the new window)
  2248.  
  2249. not yet documented
  2250.  
  2251. ==============================================================================
  2252. Cursor
  2253. ======
  2254.  
  2255. not yet documented
  2256.  
  2257. ==============================================================================
  2258. Special Effects
  2259. ===============
  2260.  
  2261. not yet documented
  2262.  
  2263. ==============================================================================
  2264. Windowing
  2265. =========
  2266.  
  2267. not yet documented
  2268.  
  2269. ==============================================================================
  2270. -----------------------------------  TIMER  ----------------------------------
  2271.  
  2272. NOTES:
  2273. > Timer identification numbers start at 0 and increase by 1 (so the first timer
  2274.   has timer_id = 0, the second has timer_id = 1, ...).
  2275. > If you supply a timer_id that is greater than the number of timers, then the
  2276.   next free timer_id will be used and returned.  For example:
  2277.     timer timers(2);                   // allocate timers (timer_id 0, 1)
  2278.     word id = timers.set(10, 5);       // id = 2 and a new timer is allocated
  2279.                     // now there are three allocated timers (wTimerId 0, 1, 2)
  2280.  
  2281. constructor: timer(word wNumber_init = 1);
  2282. > initially set up "wNumber_init" timers
  2283.  
  2284. bool done(word wTimerId);
  2285. > RETURNS  true  - "wTimerId" has finished
  2286.            false - "wTimerId" has not yet finished
  2287.  
  2288. word get_number();
  2289. > RETURNS  current number of timers
  2290.  
  2291. word set(word nLength);
  2292. > create a new timer and set it to "nLength" clock ticks
  2293. > RETURNS  id of timer created
  2294.  
  2295. void set(TimerId, word nLength);
  2296. > set "wTimerId" to "nLength"
  2297.  
  2298. void reset(word wTimerId);
  2299. > reset "wTimerId" to 0
  2300.  
  2301. EXAMPLE PROGRAM:
  2302.  
  2303. #include "bestcpp.hpp"
  2304.  
  2305. void main()
  2306. {
  2307.   timer stopwatch;                     // one timer initially
  2308.   timer tm(2);                         // two timers initially
  2309.   tm.set(0, 10);                       // set first timer to 10 clock ticks
  2310.   tm.set(1, 15);                       // set second timer to 15 clock ticks
  2311.  
  2312.   tm.set(5, 18);                       // more timers will be created
  2313.   /* since there were only 2 timers and we specified wTimerId = 5, timers
  2314.      upto wTimerId = 5 will be created automatically */
  2315.  
  2316.   word j = tm.set(21);           // this will create a new timer, set it to
  2317.   cout << "j = " << j << endl;   //  21 clock ticks and return its id (to j)
  2318. }
  2319.  
  2320. ==============================================================================
  2321.  
  2322. ======================== END OF LIBRARY DOCUMENTATION ==========================
  2323.  
  2324.  
  2325. ==============================================================================
  2326. -------------------------  HOW TO CONTACT THE AUTHOR  ------------------------
  2327.  
  2328. If you have any comments or questions regarding this library or any other
  2329. program written by me, George Vanous, feel free to reach me via email at
  2330.   vanous@helix.net
  2331. or call me at (604)589-2675 or write to me:  George Vanous
  2332.                                              8930 Watson Court
  2333.                                              Delta, BC, CAN
  2334.                                              V4C 4T6
  2335.  
  2336. ==============================================================================
  2337. ---------------------------  PROGRAMMING PITFALLS  ---------------------------
  2338.  
  2339. = in a multi-file project where the files not being edited are linked in as
  2340.   .OBJs, take GREAT care to update the .OBJs when the .HPP files they use are
  2341.   updated
  2342.   - if this is not done, the wrong functions may be called (hide may call show)
  2343. = new char[100];                       // this makes an array of char
  2344.   new (char *)[100];                   // this DOES NOT make an array of char *
  2345.   - (char *) is interpreted as a type cast and makes an array of integers
  2346.   - to make an array of char pointers, you must create a new type:
  2347.     typedef char * pChar;
  2348.     new pChar[100];                    // this makes an array of char *
  2349. = never hold onto addresses of variables declared inside a function
  2350.   - when the function terminates, these variables are destroyed
  2351.   - if you try to write to these now-nonexistent variable address: BOOM!
  2352. = enums are considered to be 2-byte ints
  2353.   - enum bool { false, true} does not take 1 byte, but 2 bytes to store
  2354. = bool is_empty() { return bool(head); }
  2355.   - is head = 0, is_empty should return true
  2356.   - this needs to be written return bool(!head);
  2357. = take great care to dynamically allocate enough memory and initialize pointers
  2358. = beware of endless loops:
  2359.     int i = 0;
  2360.     while (i < 5)
  2361.       anWindowID[i]->show();  // FORGOT THE INCREMENT -> ...[i++]->show();
  2362. = compiler complaints:
  2363.   - unreachable code
  2364.     - neverending loop (ie. while (1 < 10) instead of while (i < 10))
  2365.     - premature return statement
  2366. = computer simulations of Michael Jordan:
  2367.   - jams during compilation: unbalanced braces
  2368.   - jams before execution: a breakpoint inside an include file
  2369. = repeat rate on keyboard is unusually slow
  2370.   - you may be calling a clear_buffer() function just prior to calling get_ch()
  2371. = always put only one command inside a ternary operator if/else slot:
  2372.     y = ((x == 2) ? 1 : 0);
  2373.   - NEVER do something like this (only ONE command (not both) is executed):
  2374.     ((x == 2) ? move(1, 0); y = 0 : move(0, 1); y = 1);
  2375. = if (x == 2)
  2376.     if (y == 2)
  2377.       z = 0;
  2378.   else                  // WARNING  this "else" is with the second "if"
  2379.     z = 1;
  2380.   - if y != 2, then z = 1 -- IOW, here is how the compiler interprets this:
  2381.       if (x == 2)
  2382.         if (y == 2)
  2383.           z = 0;
  2384.         else
  2385.           z = 1;
  2386.   - to associate the "else" with the first "if", use braces:
  2387.       if (x == 2) {
  2388.         if (y == 2)
  2389.           z = 0;
  2390.       }
  2391.       else
  2392.         z = 1;
  2393.  
  2394. ==============================================================================
  2395. -----------------------------  PROGRAMMING TIPS  -----------------------------
  2396.  
  2397. = to save compile time in a multi-file project, change the project to include
  2398.   the .OBJs of those files that are not being edited
  2399. = if testing for zero or nonzero, user ! and (blank) -- faster
  2400.   - bad:  if (empty == 0)   or   if (keypressed == 1)
  2401.   - good: if (!empty)       or   if (keypressed)
  2402. = for infinite loops, use while (true) instead of for (;;) -- faster
  2403. = minimize number of memory allocations -- faster
  2404.   - bad:  icon = new int[100]; icon_bg = new int[100];
  2405.   - good: icon = new int[200]; icon_bg = icon+100;
  2406. = use "#define"s instead of "const"s because "#define"s don't use up memory
  2407. = use inline keyword for short functions -- faster
  2408. = use static keyword for often-used functions -- less memory
  2409.   - static functions are not passed a this pointer, it must be done explicitly
  2410. = to remove warning of "parameter not used" in, for example, main:
  2411.     main(int, char **, char **)
  2412.   unnamed parameters do not receive these warnings
  2413. = try to declare all loop variables just before the loop, and as single
  2414.   letters of type int:
  2415.     int i;
  2416.     for (i = 0; i < nLength; i++) { ... }
  2417. = use unnamed local variables if they are used only once:
  2418.     main(int, char **) {
  2419.       return DApp().Run();
  2420.     }
  2421.   instead of:
  2422.     main(int, char **) {
  2423.       DApp MinApp;
  2424.       return MinApp.Run();
  2425.     }
  2426.   or, worse yet:
  2427.     main(int, char **) {
  2428.       DApp *pMinApp;
  2429.       int iRetVal;
  2430.  
  2431.       pMinApp = new DApp();
  2432.       iRetVal = pMinApp->Run();
  2433.       delete pMinApp;
  2434.  
  2435.       return iRetVal;
  2436.     }
  2437. = all typedef struct should have a tag:
  2438.     typedef struct tagRECT {
  2439.       int left;
  2440.       int top;
  2441.       int right;
  2442.       int bottom;
  2443.     } RECT;
  2444.   this will allow referencing this structure inside it (like for linked lists)
  2445.  
  2446. ==============================================================================
  2447. -----------------------------  PROGRAMMING IDEAS  ----------------------------
  2448.  
  2449. = TEXT MODE
  2450.   - text file cataloging/indexing with a personal diary section (like GPE)
  2451.   - CD-ROM cataloging software (like the one on the Tech Arsenal CD)
  2452.     - create a FILES.BBS format
  2453.       - allow one line description to encourage brevity and conciseness
  2454.     - user can create a USEFUL section where he documents his useful programs
  2455.       - used as a quick-reference, instead of browsing entire CD-ROM
  2456.   - quick calendar pop-up
  2457. = file randomizer that will pick from a list of files to copy to one file
  2458.   - great for randomizing the startup screen for BBS's
  2459. = sphere rotation with name rotating on surface of sphere
  2460. = installation program exactly like Symantec's Norton Utilities 8.0
  2461. = C++ tutorial (actually, any language tutorial)
  2462. = C to Pascal converter (and Pascal to C)
  2463. = a program that will train memory by reviewing knowledge (integrate with REdit)
  2464.   - maybe even a TSR that pops up occassionally
  2465.   - also one that pops up random letters/words/numbers and asks them to be
  2466.     repeated (backwards or forwards) and keeps records of progress
  2467.     - also has world averages for this sort of thing for comparison (IQ style)
  2468. = cable tray program
  2469. = 3-dimensional spreadsheet
  2470. = document cover all facets of psychology behind commercials and human control
  2471.   - similar to Stutfen's the Battle for Your Mind -- not as superficial
  2472.   - cover all aspects of society, such as Mofia and other underestimated groups
  2473.     - standard psychological tricks used by commercials
  2474.       - repetitiveness
  2475.       - brainwashing attempts
  2476.         - subliminal messages
  2477.           - hidden behind music
  2478.           - flashing too fast for conscious cognition
  2479.       - humor
  2480.         - "I don't know why I throw these small parties.  A few people I don't
  2481.            know, a few people I don't like.  The only thing I am not being
  2482.            hassled about is my fine choice of beer.  I don't know why I throw
  2483.            these small parties.  I should throw a big one."
  2484.       - celebrities state their preference to that project
  2485. = REGISTRATION IDEAS
  2486.   - input subliminal messages to encourage registration: "register"
  2487.   - at end of program, have little guy walk up with sign saying "Register"
  2488. = SPECIAL EFFECTS
  2489.   - clear the screen with two yellow lines moving up from the center, clearing
  2490.     as they go (like in The Gathering '94, TG94INV!, introduction)
  2491.     - stop to create a small message window, display quick message
  2492.     - then, clear screen by going all the way up
  2493.   - scroller that looks like going over rapids (stretched) at some points
  2494.   - for a title of a program, superimpose one word (in brighter colors) onto
  2495.     another word (larger, of course) (remember Just Buttons)
  2496.   - a ball on chain swinging into and out of the screen (for 3D effect)
  2497.   - starfield layers (like BB-TP4.ZIP)
  2498.     - move pixels across the screen, the further ones darker colored
  2499.   - clear the screen by starting at a corner and drawing a straight line,
  2500.     sweeping it around the screen
  2501.     - do this at each corner for a neat effect (like DEMOAI.EXE, HDILOAD demo)
  2502.   - 3D rotating Rubik's Cube
  2503.   - 3D rotating opitcal illusion (three prongs).
  2504.   - water/wave effect (top view)
  2505.     - have the water "on top" of a bitmap, and distort it
  2506.   - Spotlight effect (with shadows)
  2507.   - Film countdown (leader) for beginning of demo
  2508.   - End scroller where it starts scrolling when there is something going on in
  2509.     the background, then the background fades to black and the scroller
  2510.     continues (like in the movies)
  2511.   - 64 pixels of a picture placed randomly on screen
  2512.     - come together in 64 steps each to form the picture
  2513.   - similar to ULTRAMOD.EXE, have a window (of very dark grey background) and
  2514.     a totally black background outside this window
  2515.     - move this window around, showing different sections of the screen
  2516. = GAMES
  2517.   - obstacle course
  2518.     - REMEMBER: house rotation with one house in the center orbited by two
  2519.                 houses (orbiting in opposite directions) -- you could just make
  2520.                 it out of the center by moving to the right, but not to the left
  2521.                 because, to the right, the rooves, being slanted, offered a
  2522.                 little more time before collision
  2523.   - dig dug
  2524.   - pong kombat
  2525.     - like original pong with fatalities
  2526.   - Mario brothers like game for 2-player simple fun
  2527.   - Super-Mario brothers like game where one jumps around a lot
  2528.   - space invaders (like on Intelivision)
  2529.   - asteroids
  2530.   - arkanoid
  2531.   - tank wars
  2532.     - two tanks on screen moving around
  2533.     - limited shot range and bounce of wall option (default on)
  2534.     - buy weapons (grenades, mines, shoot-over-wall shots, etc.)
  2535.   - pac-man (CD-MAN)
  2536.     - large, scrolling screen (also a version with full screen viewed)
  2537.     - random maze option
  2538.     - multiplayer option (modem/network/simultaneous)
  2539.   - space invaders
  2540.     - control a ship on the bottom (possibly with some protective blocks)
  2541.     - shoot the aliens that are slowly moving down toward you
  2542.     - the occassional flying saucer flies across the top of the screen (bonus)
  2543.   - from netnews article, women say they like Tetris because it is non-violent
  2544.     and is self-competitive (there is no monster or villian to defeat)
  2545.     - "multiple paths to winning and is in competition with yourself, not
  2546.       another "monster" or player"
  2547.     - try incorporating this idea into a game
  2548.   - Ultima V/Sword Quest style game
  2549.   - Slip N' Slide type car racing game
  2550.     - similar to OffRoad
  2551.   - look at Texas Instruments games
  2552.     - Car Wars
  2553.     - Munch Man
  2554.     - Parsec
  2555.   - look at Commodore games
  2556.     - Mario Brothers
  2557.     - Space Taxi
  2558.     - Oil's Well
  2559.   - Castle of the Winds/Sword Quest/Legend of Zelda game
  2560.   - have credits inside the game (like Corridor 7)
  2561.     - as you walk around, show them on walls, maybe floating in the air
  2562.     - just in the beginning of the game
  2563.   - big-top game
  2564.   - catchem game
  2565.   - tank game of two players onscreen with rebounding bullets (like Atari tanks)
  2566.     - planes flying around the screen trying to shoot each other
  2567.   - Zoarre-type VGA 16 color DND game (old DND like Teleguard)
  2568.   - a game like realtime risk (no waiting for turn) (with time-limit option)
  2569.     - winner is who can click the fastest
  2570.     - no army fighting -- just click on square to capture it
  2571.   -
  2572.                                 Dinosaur!
  2573.                  an action packed arcade/adventure game
  2574.                  with stunning high-intensity graphics
  2575.                       by well known graphic artist
  2576.                             Thaddeus Jantzi!
  2577.  
  2578.         Here is a brief run down of my ideas of the ideal format for it..
  2579.         Any modifactions that might help, or need be made can easily be
  2580.         accomodated
  2581.  
  2582. Opening screen: Giant letters saying "DINOSAUR!" with a little caveman shown
  2583.                 running
  2584.  
  2585. Next screen: Welcome screen.  Here the player enters his name, selects
  2586.              Carnivore or Herbivore, and then selects his Dinosaur of
  2587.              the following possible
  2588.  
  2589.              CARNIVORES               HERBIVORES
  2590.              Tyrannosaur              Triceratops
  2591.              Allosaur                 Stegosaur
  2592.              Dimetrodon               Pteranodon
  2593.  
  2594.              Other dinosaurs will be added (by me) later
  2595.              This is iffy... but it would be neat if the player could design
  2596.              his own dinosaur.  That can be arranged later if possible
  2597.  
  2598. Game!
  2599. The player will work his way through a number of levels.
  2600.  
  2601. Players must avoid obstacles such as volcanoes, falling rocks, lightning bolts
  2602. earthquakes, rivers and lakes.
  2603.  
  2604. The object for a carnivore is to destroy as much foliage as possible, and
  2605. destroy a herbivore at the end of each level.
  2606.  
  2607. The object for a herbivore is to eat as much foliage as possible and protect
  2608. itself from a carnivore at the end of each level.
  2609.  
  2610. Each dinosaur will have two attacks... defined on the selection screen
  2611.  
  2612. High scores will be based on foliage eaten, destroyed, etc.
  2613.  
  2614. ==============================================================================
  2615. ---------------------------  PROGRAMMING QUESTIONS  --------------------------
  2616.  
  2617. Q what is this LIFE program I see in many BASIC compilers?
  2618. Q what is a good algorithm to generate a maze that always has a solution?
  2619. Q how to scroll smoothly horizontally/vertically in text and graphics mode
  2620. Q how to safely reprogram the timer chip to oscillate x times faster
  2621. Q how doe one find out where the "null pointer assignment" is occurring?
  2622.   A set a watch on the following expressions:
  2623.       *(char *)0,4m
  2624.       *(char *)4
  2625.     and step through the program; when the values change, the just-executed
  2626.     line is the one that is causing the problem
  2627.  
  2628. ==============================================================================
  2629. ---------------------------------  DOS DEBUG  --------------------------------
  2630.  
  2631. a        - begin assembly (mov ax,bx    shr cx,1    etc.)
  2632. e        - begin hex input at the current offset
  2633. u        - unassemble (show the assembler instructions)
  2634. d     - show a memory dump (hex values)
  2635. d100     - show a memory dump beginning at offset 100 hex
  2636. da000:10 - show a memory dump beginning at segment A000 offset 10 hex
  2637. NOTE     - this convention of appending numbers also works for a, e and u
  2638.  
  2639. r        - show the current register contents
  2640. rax      - register AX (set a value for register AX)
  2641. rbx...   - register BX, register CX (rcx) (rdx, rbp, rds, etc.)
  2642. t        - trace the next instruction (like F7 in Pascal)
  2643. p        - proceed through the next instruction (like F8 in Pascal)
  2644. NOTE     - the difference between t and p is very important!  If the next
  2645.            instruction is a CALL, then t will trace INTO that call whereas p
  2646.            will treat CALL as one instruction.  p will perform the call and
  2647.            return control to you after the call has completed.
  2648.  
  2649. ==============================================================================
  2650. ------------------------------  FREEWARE TITLES  -----------------------------
  2651.  
  2652. This list is woefully incomplete.  If you can add on to it, please contact me.
  2653.  
  2654. ---
  2655.  
  2656. GAME PROGRAMMER'S ENCYCLOPEDIA
  2657.  - excellent source of tutorials and demos with full source
  2658.  - WHERE IS IT?  teeri.oulu.fi  pub/msdos/programming/gpe/pcgpe10.zip
  2659.  
  2660. ---
  2661.  
  2662. LINUX
  2663.  - probably the best operating system for the 386+ PC (undeniably the fastest)
  2664.  - supports DOS, OS/2, WINDOWS NT, etc. disk file formats
  2665.  - WHERE IS IT?  (unknown ftp site)
  2666.  
  2667. ---
  2668.  
  2669. THE BESTLIBRARY++
  2670.  - robust C++ object library (author welcomes code contributions)
  2671.  - WHERE IS IT?  still under development -- contact author at vanous@helix.net
  2672.  
  2673. ---
  2674.  
  2675. ==============================================================================
  2676. --------------------------------  DISCLAIMER  --------------------------------
  2677.  
  2678. To the best of my ability (and that is damn good), I have made all versions of
  2679. The BESTLibrary++ error free, compatible with all IBM PC clones, and free of
  2680. viruses, trojans, and the common cold.  I, or anybody related to the
  2681. development of this software, cannot be held accountable for the behavior of
  2682. the enclosed program(s) or file(s) and assume no liability for damages either
  2683. from the direct use or as a consequence of the use/misuse of this product.
  2684. Hence, this program and all information contained within should be used at
  2685. one's own risk.
  2686.  
  2687. This disclaimer is included to absolve me from the legal issues brought about
  2688. by today's litigious society.
  2689.  
  2690. ==============================================================================
  2691.  
  2692. ===PERSONAL NOTES
  2693.  
  2694. To rotate vector A about vector B (right hand rule), theta radians:
  2695.   new vector = Dot(A,B)*B + Sin(theta)*Cross(B,A) + Cos(theta)*Dot(B,Cross(A,B))
  2696.  
  2697. = make two versions for each data type:
  2698.   - 1) take in pointers to objects
  2699.   - 2) take in objects
  2700. = make a version that serves as a tutorial (for novices)
  2701.   - show them step-by-step how to use the common functions
  2702.  
  2703. FILE_ID.DIZ
  2704. Robust FREEWARE C++ object library with
  2705. full source code!  2D/3D graphics, data
  2706. types, text mode control, text/graphics
  2707. windows, timers and stopwatches, direct
  2708. keyboard control, and much more!
  2709.  
  2710. ==============================================================================
  2711.  
  2712. REALiTY
  2713.